Interface Datum

All Known Subinterfaces:
AcDcEnergyDatum, AcEnergyDatum, AtmosphericDatum, DayDatum, DcEnergyDatum, EnergyDatum, EnergyStorageDatum, MutableDatum, PriceDatum
All Known Implementing Classes:
GeneralDatum

public interface Datum
Basic persistable domain object API.
Version:
2.0
Author:
matt
  • Field Details

    • REVERSE_ACCUMULATING_SUFFIX_KEY

      static final String REVERSE_ACCUMULATING_SUFFIX_KEY
      A suffix to append to to data property keys that represent a logical reverse of the same key without this suffix. For example a wattHoursReverse key might represent energy exported, rather than imported, through a power meter.
      See Also:
    • DATUM_TYPE_PROPERTY

      static final String DATUM_TYPE_PROPERTY
      A property name for the string name of the core datum type a datum represents.

      The core data type is the most specific interface defined on a datum class, which will be the first value in the DATUM_TYPES_PROPERTY property.

      See Also:
    • DATUM_TYPES_PROPERTY

      static final String DATUM_TYPES_PROPERTY
      A property name for an array of string names of all datum types associated with the event.

      Datum types are the fully qualified interfaces defined on the datum implementation class, and any superclass. All Java language interfaces are ignored, e.g. packages starting with java. or javax. are not included. The array is ordered in reverse class hierarchy order.

      See Also:
    • OP_STATE

      static final String OP_STATE
      A status sample key for a DeviceOperatingState.getCode() value.
      See Also:
    • OP_STATES

      static final String OP_STATES
      A status sample key for a bitmask of hardware-specific operating state values.
      See Also:
    • TIMESTAMP

      static final String TIMESTAMP
      A sample data key for a getTimestamp() value, as a long millisecond epoch value or ISO 8601 formatted string.
      See Also:
    • SOURCE_ID

      static final String SOURCE_ID
      A sample data key for a getSourceId() value.
      See Also:
  • Method Details

    • getKind

      ObjectDatumKind getKind()
      Get the object kind.
      Returns:
      the object kind
    • getObjectId

      Long getObjectId()
      Get a domain-specific ID related to the object kind.
      Returns:
      the object ID, or null
    • getTimestamp

      Instant getTimestamp()
      Get the date this datum is associated with, which is often equal to either the date it was persisted or the date the associated data in this object was captured.
      Returns:
      the timestamp
    • getSourceId

      String getSourceId()
      Get a unique source ID for this datum.

      A single datum type may collect data from many different sources.

      Returns:
      the source ID
    • getSampleData

      Map<String,?> getSampleData()
      Get a map of all available data sampled or collected on this datum.
      Returns:
      a map with all available sample data
    • asSimpleMap

      Map<String,?> asSimpleMap()
      Get a simple Map view of this datum.

      The returned map should include all the available properties of this datum, in as flat of a structure as possible, i.e. without nested maps. The property values should be composed only if simple Java types like numbers, strings, and arrays or lists of those types. It should also include the DATUM_TYPE_PROPERTY and DATUM_TYPES_PROPERTY values.

      Returns:
      a Map view of this datum
    • asSampleOperations

      DatumSamplesOperations asSampleOperations()
      Get a general accessor for the sample data.
      Returns:
      the operations instance, never null
    • copyWithSamples

      Datum copyWithSamples(DatumSamplesOperations samples)
      Create a copy of this instance with the sample properties replaced by a given samples instance.
      Parameters:
      samples - the samples to use for the copy
      Returns:
      a new copy of this instance
    • copyWithId

      Datum copyWithId(DatumId id)
      Get a copy of this datum with a new ID.

      A new samples instance will also be created.

      Parameters:
      id - the new ID to use
      Returns:
      the copy with the given ID