Class DatumSamples

java.lang.Object
net.solarnetwork.domain.datum.DatumSupport
net.solarnetwork.domain.datum.DatumSamples
All Implemented Interfaces:
Serializable, DatumSamplesOperations, MutableDatumSamplesOperations, Differentiable<DatumSamplesOperations>

public class DatumSamples extends DatumSupport implements MutableDatumSamplesOperations, Serializable
A collection of different types of sample data, grouped by logical sample type.
Version:
2.1
Author:
matt
See Also:
  • Constructor Details

    • DatumSamples

      public DatumSamples()
      Default constructor.
    • DatumSamples

      public DatumSamples(Map<String,Number> instantaneous, Map<String,Number> accumulating, Map<String,Object> status)
      Construct with values.
      Parameters:
      instantaneous - the instantaneous data
      accumulating - the accumulating data
      status - the status data
    • DatumSamples

      public DatumSamples(DatumSamplesOperations other)
      Copy constructor.
      Parameters:
      other - the samples to copy
      Since:
      1.4
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clear

      public void clear()
      Clear all property values.
      Specified by:
      clear in interface MutableDatumSamplesOperations
      Overrides:
      clear in class DatumSupport
    • getSampleData

      public Map<String,?> getSampleData()
      Get a merged map of all sample data.
      Returns:
      a map with all sample data combined
    • isEmpty

      public boolean isEmpty()
      Test if there are any properties configured in the instantaneous, accumulating, status, or tag data sets.
      Specified by:
      isEmpty in interface DatumSamplesOperations
      Returns:
      true if there is at least one value in one of the data sets of this object
      Since:
      1.3
    • getSampleData

      public Map<String,?> getSampleData(DatumSamplesType type)
      Description copied from interface: DatumSamplesOperations
      Get specific sample data.
      Specified by:
      getSampleData in interface DatumSamplesOperations
      Parameters:
      type - the type of sample data to get
      Returns:
      a map with the specific sample data, or null
    • setSampleData

      public void setSampleData(DatumSamplesType type, Map<String,?> data)
      Description copied from interface: MutableDatumSamplesOperations
      Set specific sample data.

      In the case of DatumSamplesType.Tag the keys of data will be used as the tag values to save.

      Specified by:
      setSampleData in interface MutableDatumSamplesOperations
      Parameters:
      type - the type of sample data to set
      data - the data to set; this is cast to the appropriate type without checking
    • getSampleInteger

      public Integer getSampleInteger(DatumSamplesType type, String key)
      Description copied from interface: DatumSamplesOperations
      Get an Integer value from a sample map, or null if not available.
      Specified by:
      getSampleInteger in interface DatumSamplesOperations
      Parameters:
      type - the type of sample data to get
      key - the key of the value to get
      Returns:
      the value as an Integer, or null if not available
    • getSampleLong

      public Long getSampleLong(DatumSamplesType type, String key)
      Description copied from interface: DatumSamplesOperations
      Get a Long value from a sample map, or null if not available.
      Specified by:
      getSampleLong in interface DatumSamplesOperations
      Parameters:
      type - the type of sample data to get
      key - the key of the value to get
      Returns:
      the value as an Long, or null if not available
    • getSampleFloat

      public Float getSampleFloat(DatumSamplesType type, String key)
      Description copied from interface: DatumSamplesOperations
      Get a Float value from a sample map, or null if not available.
      Specified by:
      getSampleFloat in interface DatumSamplesOperations
      Parameters:
      type - the type of sample data to get
      key - the key of the value to get
      Returns:
      the value as an Float, or null if not available
    • getSampleDouble

      public Double getSampleDouble(DatumSamplesType type, String key)
      Description copied from interface: DatumSamplesOperations
      Get a Double value from a sample map, or null if not available.
      Specified by:
      getSampleDouble in interface DatumSamplesOperations
      Parameters:
      type - the type of sample data to get
      key - the key of the value to get
      Returns:
      the value as an Double, or null if not available
    • getSampleBigDecimal

      public BigDecimal getSampleBigDecimal(DatumSamplesType type, String key)
      Description copied from interface: DatumSamplesOperations
      Get a BigDecimal value from a sample map, or null if not available.
      Specified by:
      getSampleBigDecimal in interface DatumSamplesOperations
      Parameters:
      type - the type of sample data to get
      key - the key of the value to get
      Returns:
      the value as an BigDecimal, or null if not available
    • getSampleString

      public String getSampleString(DatumSamplesType type, String key)
      Description copied from interface: DatumSamplesOperations
      Get a String value from a sample map, or null if not available.

      If type is DatumSamplesType.Tag, then this method will return key if a tag by that name exists and otherwise it will return null.

      Specified by:
      getSampleString in interface DatumSamplesOperations
      Parameters:
      type - the type of sample data to get
      key - the key of the value, or tag name, to get
      Returns:
      the value as an String, or null if not available
    • getSampleValue

      public <V> V getSampleValue(DatumSamplesType type, String key)
      Description copied from interface: DatumSamplesOperations
      Get a sample value.

      If type is DatumSamplesType.Tag, then this method will return key if a tag by that name exists and otherwise it will return null.

      Specified by:
      getSampleValue in interface DatumSamplesOperations
      Type Parameters:
      V - the expected value type
      Parameters:
      type - the type of sample data to get
      key - the key of the value, or tag name, to get
      Returns:
      the value cast as a V, or null if not available
    • findSampleValue

      public <V> V findSampleValue(String key)
      Description copied from interface: DatumSamplesOperations
      Find a sample value.

      This will search Instantaneous, Accumulating, and Status data types, in that order, and return the first non-null value found.

      Specified by:
      findSampleValue in interface DatumSamplesOperations
      Type Parameters:
      V - the expected value type
      Parameters:
      key - the key of the value, or tag name, to get
      Returns:
      the value cast as a V, or null if not available
    • hasSampleValue

      public boolean hasSampleValue(String key)
      Description copied from interface: DatumSamplesOperations
      Test is a sample value is present for a given key.

      This will search Instantaneous, Accumulating, and Status data types, in that order, and return the first non-null value found.

      Specified by:
      hasSampleValue in interface DatumSamplesOperations
      Parameters:
      key - the key of the value, or name of the tag, to look for
      Returns:
      true if a value is present for the given key
    • putSampleValue

      public void putSampleValue(DatumSamplesType type, String key, Object value)
      Description copied from interface: MutableDatumSamplesOperations
      Add a value into or remove a value from a sample type collection, creating the collection if it doesn't already exist.

      To add a tag, pass the tag name for both key and value. To remove a tag, pass the tag name for key and null for value. To replace a tag, pass the tag to remove for key and the tag to add as value.

      For DatumSamplesType.Instantaneous and DatumSamplesType.Accumulating if value is non-null but not a Number, it will be silently ignored.

      Specified by:
      putSampleValue in interface MutableDatumSamplesOperations
      Parameters:
      type - the type of sample data to get
      key - the key to put, or tag to add/remove for DatumSamplesType.Tag
      value - the value to put, or tag to add, or null to remove the value; this will be cast without checking
    • hasSampleValue

      public boolean hasSampleValue(DatumSamplesType type, String key)
      Description copied from interface: DatumSamplesOperations
      Test is a sample value is present for a given key.

      Tags can be tested for as well by passing DatumSamplesType.Tag and the tag name as key.

      Specified by:
      hasSampleValue in interface DatumSamplesOperations
      Parameters:
      type - the type of sample data to test
      key - the key of the value, or name of the tag, to look for
      Returns:
      true if a value is present for the given key
    • putInstantaneousSampleValue

      public void putInstantaneousSampleValue(String key, Number n)
      Put a value into or remove a value from the getInstantaneous() map, creating the map if it doesn't exist.
      Parameters:
      key - the key to put
      n - the value to put, or null to remove the key
    • putAccumulatingSampleValue

      public void putAccumulatingSampleValue(String key, Number n)
      Put a value into or remove a value from the getAccumulating() map, creating the map if it doesn't exist.
      Parameters:
      key - the key to put
      n - the value to put, or null to remove the key
    • putStatusSampleValue

      public void putStatusSampleValue(String key, Object value)
      Put a value into or remove a value from the getStatus() map, creating the map if it doesn't exist.
      Parameters:
      key - the key to put
      value - the value to put, or null to remove the key
    • getInstantaneousSampleInteger

      public Integer getInstantaneousSampleInteger(String key)
      Get an Integer value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Integer, or null if not available
    • getInstantaneousSampleLong

      public Long getInstantaneousSampleLong(String key)
      Get a Long value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Long, or null if not available
    • getInstantaneousSampleFloat

      public Float getInstantaneousSampleFloat(String key)
      Get a Float value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Float, or null if not available
    • getInstantaneousSampleDouble

      public Double getInstantaneousSampleDouble(String key)
      Get a Double value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Double, or null if not available
    • getInstantaneousSampleBigDecimal

      public BigDecimal getInstantaneousSampleBigDecimal(String key)
      Get a BigDecimal value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an BigDecimal, or null if not available
    • getAccumulatingSampleInteger

      public Integer getAccumulatingSampleInteger(String key)
      Get an Integer value from the getAccumulating() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Integer, or null if not available
    • getAccumulatingSampleLong

      public Long getAccumulatingSampleLong(String key)
      Get a Long value from the getAccumulating() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Long, or null if not available
    • getAccumulatingSampleFloat

      public Float getAccumulatingSampleFloat(String key)
      Get a Float value from the getAccumulating() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Float, or null if not available
    • getAccumulatingSampleDouble

      public Double getAccumulatingSampleDouble(String key)
      Get a Double value from the getAccumulating() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Double, or null if not available
    • getAccumulatingSampleBigDecimal

      public BigDecimal getAccumulatingSampleBigDecimal(String key)
      Get a BigDecimal value from the getAccumulating() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an BigDecimal, or null if not available
    • getStatusSampleInteger

      public Integer getStatusSampleInteger(String key)
      Get an Integer value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Integer, or null if not available
    • getStatusSampleLong

      public Long getStatusSampleLong(String key)
      Get a Long value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Long, or null if not available
    • getStatusSampleFloat

      public Float getStatusSampleFloat(String key)
      Get a Float value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Float, or null if not available
    • getStatusSampleDouble

      public Double getStatusSampleDouble(String key)
      Get a Double value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an Double, or null if not available
    • getStatusSampleBigDecimal

      public BigDecimal getStatusSampleBigDecimal(String key)
      Get a BigDecimal value from the getInstantaneous() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as an BigDecimal, or null if not available
    • getStatusSampleString

      public String getStatusSampleString(String key)
      Get a String value from the getStatus() map, or null if not available.
      Parameters:
      key - the key of the value to get
      Returns:
      the value as a String, or null if not available
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getI

      public Map<String,Number> getI()
      Shortcut for getInstantaneous().
      Returns:
      map
    • setI

      public void setI(Map<String,Number> map)
      Set the instantaneous properties.
      Parameters:
      map - the properties to set
    • getA

      public Map<String,Number> getA()
      Shortcut for getAccumulating().
      Returns:
      map
    • setA

      public void setA(Map<String,Number> map)
      Set the accumulating properties.
      Parameters:
      map - the properties to set
    • getS

      public Map<String,Object> getS()
      Shortcut for getStatus().
      Returns:
      map
    • setS

      public void setS(Map<String,Object> map)
      Set the status properties.
      Parameters:
      map - the status properties to set
    • getInstantaneous

      public Map<String,Number> getInstantaneous()
      Get a map of instantaneous sample values. These values measure instant readings of something.
      Returns:
      map of instantaneous measurements
    • setInstantaneous

      public void setInstantaneous(Map<String,Number> instantaneous)
      Set the instantaneous properties.
      Parameters:
      instantaneous - the properties to set
    • getAccumulating

      public Map<String,Number> getAccumulating()
      Get a map accumulating sample values. These values measure an accumulating data value, whose values represent an offset from another sample on a different date.
      Returns:
      map of accumulating measurements
    • setAccumulating

      public void setAccumulating(Map<String,Number> accumulating)
      Set the accumulating properties.
      Parameters:
      accumulating - the properties to set
    • getStatus

      public Map<String,Object> getStatus()
      Get a map of status sample values. These are arbitrary values.
      Returns:
      map of status messages
    • setStatus

      public void setStatus(Map<String,Object> status)
      Set the status properties.
      Parameters:
      status - the properties to set