public class LevelData extends FunctionData
FunctionData
.MultiLevelControl
,
MultiLevelSensor
,
Meter
,
FunctionData
Modifier and Type | Field and Description |
---|---|
static String |
FIELD_LEVEL
Represents the level field name.
|
static String |
FIELD_UNIT
Represents the unit field name.
|
DESCRIPTION, FIELD_METADATA, FIELD_TIMESTAMP
Constructor and Description |
---|
LevelData(long timestamp,
Map<String,Object> metadata,
BigDecimal level,
String unit)
Constructs new
LevelData instance with the specified arguments. |
LevelData(Map<String,?> fields)
Constructs new
LevelData instance with the specified field
values. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Object o)
Compares this
LevelData instance with the given argument. |
boolean |
equals(Object o)
Two
LevelData instances are equal if they contain equal metadata,
timestamp, unit and level. |
BigDecimal |
getLevel()
Returns
LevelData value. |
String |
getUnit()
|
int |
hashCode()
Returns the hash code for this
LevelData object. |
String |
toString()
Returns the string representation of this level data.
|
getMetadata, getTimestamp
public static final String FIELD_LEVEL
getLevel()
. The field type is BigDecimal
. The constant
can be used as a key to LevelData(Map)
.public static final String FIELD_UNIT
getUnit()
. The field type is String
. The constant can be
used as a key to LevelData(Map)
.public LevelData(Map<String,?> fields)
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
.public LevelData(long timestamp, Map<String,Object> metadata, BigDecimal level, String unit)
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
.public BigDecimal getLevel()
LevelData
value. The value type is BigDecimal
instead of double
to guarantee value accuracy.LevelData
value.public String getUnit()
null
if the unit is missing.public boolean equals(Object o)
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.FunctionData.equals(java.lang.Object)
public int hashCode()
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
LevelData
object.FunctionData.hashCode()
public int compareTo(Object o)
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.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
.Comparable.compareTo(java.lang.Object)
Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0