Package net.solarnetwork.node.service
Class DatumEvents
java.lang.Object
net.solarnetwork.node.service.DatumEvents
Support for
NodeDatum Event handling.- Since:
- 2.0
- Version:
- 1.0
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA property name for aDatuminstance associated with an event. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.osgi.service.event.EventdatumCapturedEvent(NodeDatum datum) static org.osgi.service.event.EventdatumEvent(String topic, Class<? extends net.solarnetwork.domain.datum.Datum> clazz, Map<String, ?> datumMap) Create an event with a datum class and property map.static org.osgi.service.event.EventdatumEvent(String topic, NodeDatum datum) Create an event with a datum.datumEventMap(org.osgi.service.event.Event event) Create a map out of event properties, unwrapping datum properties.static String[]datumTypes(Class<?> clazz) Get an array of datum types for a class.
-
Field Details
-
DATUM_PROPERTY
A property name for aDatuminstance associated with an event.- Since:
- 2.0
- See Also:
-
-
Method Details
-
datumEvent
public static org.osgi.service.event.Event datumEvent(String topic, Class<? extends net.solarnetwork.domain.datum.Datum> clazz, Map<String, ?> datumMap) Create an event with a datum class and property map.- Parameters:
topic- the event topicclazz- the datum classdatumMap- the datum properties- Returns:
- the new event, or null if
datumMapis null or empty
-
datumEvent
Create an event with a datum.- Parameters:
topic- the event topicdatum- the datum to add as theDATUM_PROPERTYevent property- Returns:
- the new event instance
-
datumEventMap
Create a map out of event properties, unwrapping datum properties.If a
NodeDatumis found on theDATUM_PROPERTYevent property, then the result ofDatum.asSimpleMap()will be added to the returned map rather than the datum itself.- Parameters:
event- the event to get a map of event properties for- Returns:
- the event properties as a map, never null
-
datumCapturedEvent
Create a newDatumDataSource.EVENT_TOPIC_DATUM_CAPTUREDEventobject out of aNodeDatum.This method calls
datumEvent(String, NodeDatum).- Parameters:
datum- the datum to create the event for- Returns:
- the new event instance
- See Also:
-
datumTypes
Get an array of datum types for a class.This method caches the results for performance.
- Parameters:
clazz- the datum class to get the types for- Returns:
- the types
-