Class LevelData

    • Constructor Summary

      Constructors 
      Constructor Description
      LevelData​(long timestamp, java.util.Map<java.lang.String,​java.lang.Object> metadata, java.math.BigDecimal level, java.lang.String unit)
      Constructs new LevelData instance with the specified arguments.
      LevelData​(java.util.Map<java.lang.String,​?> fields)
      Constructs new LevelData instance with the specified field values.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.lang.Object o)
      Compares this LevelData instance with the given argument.
      boolean equals​(java.lang.Object o)
      Two LevelData instances are equal if they contain equal metadata, timestamp, unit and level.
      java.math.BigDecimal getLevel()
      Returns LevelData value.
      java.lang.String getUnit()
      Returns LevelData unit as it's specified in PropertyMetadata.UNITS or null if the unit is missing.
      int hashCode()
      Returns the hash code for this LevelData object.
      java.lang.String toString()
      Returns the string representation of this level data.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • FIELD_LEVEL

        public static final java.lang.String FIELD_LEVEL
        Represents the level field name. The field value is available with getLevel(). The field type is BigDecimal. The constant can be used as a key to LevelData(Map).
        See Also:
        Constant Field Values
      • FIELD_UNIT

        public static final java.lang.String FIELD_UNIT
        Represents the unit field name. The field value is available with getUnit(). The field type is String. The constant can be used as a key to LevelData(Map).
        See Also:
        Constant Field Values
    • Constructor Detail

      • LevelData

        public LevelData​(java.util.Map<java.lang.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.
        Parameters:
        fields - Contains the new LevelData instance field values.
        Throws:
        java.lang.ClassCastException - If the field value types are not expected.
        java.lang.IllegalArgumentException - If the level is missing.
        java.lang.NullPointerException - If the fields map is null.
      • LevelData

        public LevelData​(long timestamp,
                         java.util.Map<java.lang.String,​java.lang.Object> metadata,
                         java.math.BigDecimal level,
                         java.lang.String unit)
        Constructs new LevelData instance with the specified arguments.
        Parameters:
        timestamp - The data timestamp optional field.
        metadata - The data metadata optional field.
        level - The level value mandatory field.
        unit - The data unit optional field.
        Throws:
        java.lang.NullPointerException - If level is null.
    • Method Detail

      • getLevel

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

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

        public boolean equals​(java.lang.Object o)
        Two LevelData instances are equal if they contain equal metadata, timestamp, unit and level.
        Overrides:
        equals in class FunctionData
        Parameters:
        o - The object to compare this data.
        Returns:
        true if this object is equivalent to the specified one.
        See Also:
        FunctionData.equals(java.lang.Object)
      • 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.
        Overrides:
        hashCode in class FunctionData
        Returns:
        The hash code of this LevelData object.
        See Also:
        FunctionData.hashCode()
      • compareTo

        public int compareTo​(java.lang.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 java.lang.Comparable<java.lang.Object>
        Overrides:
        compareTo in class FunctionData
        Parameters:
        o - LevelData to be compared.
        Returns:
        -1, 0 or 1 depending on the comparison rules.
        Throws:
        java.lang.ClassCastException - If the method argument is not of type LevelData.
        See Also:
        Comparable.compareTo(java.lang.Object)
      • toString

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