All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.newrelic.insights.publish.Event Maven / Gradle / Ivy

The newest version!
package com.newrelic.insights.publish;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

public class Event {

	private static final String PROPERTY_NAME_EVENT_TYPE = "eventType";
	private static ObjectMapper mapper = new ObjectMapper();
	private ObjectNode objectNode;
	
	public Event(String eventType) {
		objectNode = mapper.createObjectNode();
		objectNode.put(PROPERTY_NAME_EVENT_TYPE, eventType);
	}
	
	public static Event create(String eventType) {
		Event event = new Event(eventType);
		return event;
	}
	
	public Event put(String key, String value) {
		objectNode.put(key, value);
		return this;
	}
	
	public Event put(String key, Double value) {
		objectNode.put(key, value);
		return this;
	}
	
	public Event put(String key, Float value) {
		objectNode.put(key, value);
		return this;
	}
	
	public Event put(String key, Integer value) {
		objectNode.put(key, value);
		return this;
	}
	
	public Event put(String key, Long value) {
		objectNode.put(key, value);
		return this;
	}
	
	public Event put(String key, Short value) {
		objectNode.put(key, value);
		return this;
	}
	
	@Deprecated
	public Event put(String key, Object value) {
		if(value == null) {
			return this;
		}
		objectNode.putPOJO(key, value);
		return this;
	}

	protected ObjectNode getObjectNode() {
		return objectNode;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy