com.newrelic.insights.publish.Event Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of insights_client Show documentation
Show all versions of insights_client Show documentation
a java client library for posting events to New Relic Insights
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;
}
}