Class DatumProperties

java.lang.Object
net.solarnetwork.domain.datum.DatumProperties
All Implemented Interfaces:
Serializable

public class DatumProperties extends Object implements Serializable
A collection of property values for a datum.

The properties are stored as ordered arrays of values. The meaning of the values depends on external DatumStreamMetadata. null values are allowed both as the array fields of this class and as values within array instances.

Since:
1.72
Version:
1.2
Author:
matt
See Also:
  • Constructor Details

    • DatumProperties

      public DatumProperties()
  • Method Details

    • propertiesOf

      public static DatumProperties propertiesOf(BigDecimal[] instantaneous, BigDecimal[] accumulating, String[] status, String[] tags)
      Create a datum properties instance.
      Parameters:
      instantaneous - the instantaneous values
      accumulating - the accumulating values
      status - the status values
      tags - the tag values
      Returns:
      the new instance, never null
    • propertiesFrom

      public static DatumProperties propertiesFrom(Datum datum, ObjectDatumStreamMetadata meta) throws IllegalArgumentException
      Create a new instance out of a general datum and associated stream metadata.

      Note that trailing null values will be removed from the instantaneous, accumulating, and status data arrays.

      Parameters:
      datum - the datum to create properties from
      meta - the metadata that defines the property order
      Returns:
      the properties, or null if datum is null
      Throws:
      IllegalArgumentException - if the metadata does not support a property found on the datum
    • hashCode

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

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

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

      public int getLength()
      Get the overall number of array property values.

      This returns the sum of the length of all the array fields of this class.

      Returns:
      the number of values (including null values)
    • getInstantaneousLength

      public int getInstantaneousLength()
      Get the instantaneous values array length.
      Returns:
      the number of instantaneous values (including null values)
    • getInstantaneous

      public BigDecimal[] getInstantaneous()
      Get the instantaneous values.
      Returns:
      the instantaneous sample values
    • setInstantaneous

      public void setInstantaneous(BigDecimal[] values)
      Set the instantaneous values.
      Parameters:
      values - the values to set
    • instantaneousValue

      public BigDecimal instantaneousValue(int index)
      Get the value of a specific instantaneous property by index.
      Parameters:
      index - the property index to return
      Returns:
      the value, or null if not available
      Since:
      1.2
    • getAccumulatingLength

      public int getAccumulatingLength()
      Get the accumulating values array length.
      Returns:
      the number of accumulating values (including null values)
    • getAccumulating

      public BigDecimal[] getAccumulating()
      Get the accumulating values.
      Returns:
      the accumulating sample values
    • setAccumulating

      public void setAccumulating(BigDecimal[] values)
      Set the accumulating values.
      Parameters:
      values - the values to set
    • accumulatingValue

      public BigDecimal accumulatingValue(int index)
      Get the value of a specific accumulating property by index.
      Parameters:
      index - the property index to return
      Returns:
      the value, or null if not available
      Since:
      1.2
    • getStatusLength

      public int getStatusLength()
      Get the status values array length.
      Returns:
      the number of status values (including null values)
    • getStatus

      public String[] getStatus()
      Get the status values.
      Returns:
      the status sample values
    • setStatus

      public void setStatus(String[] status)
      Set the status values.
      Parameters:
      status - the values to set
    • statusValue

      public String statusValue(int index)
      Get the value of a specific status property by index.
      Parameters:
      index - the property index to return
      Returns:
      the value, or null if not available
      Since:
      1.2
    • getTagsLength

      public int getTagsLength()
      Get the tags array length.
      Returns:
      the number of tags (including null values)
    • getTags

      public String[] getTags()
      Get the tag values.
      Returns:
      the tag values
    • setTags

      public void setTags(String[] tags)
      Set the tag values.
      Parameters:
      tags - the tags to set
    • hasTag

      public boolean hasTag(String tag)
      Test if a specific tag exits (case-insensitive).
      Parameters:
      tag - the tag to test for
      Returns:
      true if the given tag is present in the getTags() array
      Since:
      1.2