Class LevelData

All Implemented Interfaces:

public class LevelData extends FunctionData
Function level data wrapper. It supports all properties defined in FunctionData.
See Also:
  • Field Details

  • Constructor Details

    • LevelData

      public LevelData(Map<String,?> fields)
      Constructs new LevelData instance with the specified field values. The map keys must match to the field names. The map values will be assigned to the appropriate class fields. For example, the maps can be: {"level"=BigDecimal(1)...}. That map will initialize the FIELD_LEVEL field with 1.
      • FIELD_LEVEL - mandatory field. The value type must be BigDecimal.
      • FIELD_UNIT - optional field. The value type must be String.
      fields - Contains the new LevelData instance field values.
      ClassCastException - If the field value types are not expected.
      IllegalArgumentException - If the level is missing.
      NullPointerException - If the fields map is null.
    • LevelData

      public LevelData(long timestamp, Map<String,Object> metadata, BigDecimal level, String unit)
      Constructs new LevelData instance with the specified arguments.
      timestamp - The data timestamp optional field.
      metadata - The data metadata optional field.
      level - The level value mandatory field.
      unit - The data unit optional field.
      NullPointerException - If level is null.
  • Method Details

    • getLevel

      public BigDecimal getLevel()
      Returns LevelData value. The value type is BigDecimal instead of double to guarantee value accuracy.
      The LevelData value.
    • getUnit

      public String getUnit()
      Returns LevelData unit as it's specified in PropertyMetadata.UNITS or null if the unit is missing.
      The value unit or null if the unit is missing.
    • equals

      public boolean equals(Object o)
      Two LevelData instances are equal if they contain equal metadata, timestamp, unit and level.
      equals in class FunctionData
      o - The object to compare this data.
      true if this object is equivalent to the specified one.
      See Also:
    • hashCode

      public int hashCode()
      Returns the hash code for this LevelData object. The hash code is a sum of FunctionData.hashCode(), String.hashCode() and BigDecimal.hashCode(), where String.hashCode() represents the unit hash code and BigDecimal.hashCode() represents the level hash code.
      hashCode in class FunctionData
      The hash code of this LevelData object.
      See Also:
    • compareTo

      public int compareTo(Object o)
      Compares this LevelData instance with the given argument. If the argument is not LevelData, it throws ClassCastException. Otherwise, this method returns:
      • -1 if this instance field is less than a field of the specified argument.
      • 0 if all fields are equivalent.
      • 1 if this instance field is greater than a field of the specified argument.
      The fields are compared in this order: timestamp, metadata, level, unit.
      Specified by:
      compareTo in interface Comparable<Object>
      compareTo in class FunctionData
      o - LevelData to be compared.
      -1, 0 or 1 depending on the comparison rules.
      ClassCastException - If the method argument is not of type LevelData.
      See Also:
    • toString

      public String toString()
      Returns the string representation of this level data.
      toString in class Object
      The string representation of this level data.