Class DatumEvents

java.lang.Object
net.solarnetwork.node.service.DatumEvents

public final class DatumEvents extends Object
Support for NodeDatum Event handling.
Since:
2.0
Version:
1.0
Author:
matt
  • Field Details

    • DATUM_PROPERTY

      public static final String DATUM_PROPERTY
      A property name for a Datum instance 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 topic
      clazz - the datum class
      datumMap - the datum properties
      Returns:
      the new event, or null if datumMap is null or empty
    • datumEvent

      public static org.osgi.service.event.Event datumEvent(String topic, NodeDatum datum)
      Create an event with a datum.
      Parameters:
      topic - the event topic
      datum - the datum to add as the DATUM_PROPERTY event property
      Returns:
      the new event instance
    • datumEventMap

      public static Map<String,Object> datumEventMap(org.osgi.service.event.Event event)
      Create a map out of event properties, unwrapping datum properties.

      If a NodeDatum is found on the DATUM_PROPERTY event property, then the result of Datum.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

      public static org.osgi.service.event.Event datumCapturedEvent(NodeDatum datum)
      Create a new DatumDataSource.EVENT_TOPIC_DATUM_CAPTURED Event object out of a NodeDatum.

      This method calls datumEvent(String, NodeDatum).

      Parameters:
      datum - the datum to create the event for
      Returns:
      the new event instance
      See Also:
    • datumTypes

      public static String[] datumTypes(Class<?> clazz)
      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