Class LevelData
java.lang.Object
org.osgi.service.dal.FunctionData
org.osgi.service.dal.functions.data.LevelData
- All Implemented Interfaces:
Comparable<Object>
Function level data wrapper. It supports all properties defined in
FunctionData
.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Represents the level field name.static final String
Represents the unit field name.Fields inherited from class org.osgi.service.dal.FunctionData
DESCRIPTION, FIELD_METADATA, FIELD_TIMESTAMP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Compares thisLevelData
instance with the given argument.boolean
TwoLevelData
instances are equal if they contain equal metadata, timestamp, unit and level.getLevel()
ReturnsLevelData
value.getUnit()
int
hashCode()
Returns the hash code for thisLevelData
object.toString()
Returns the string representation of this level data.Methods inherited from class org.osgi.service.dal.FunctionData
getMetadata, getTimestamp
-
Field Details
-
FIELD_LEVEL
Represents the level field name. The field value is available withgetLevel()
. The field type isBigDecimal
. The constant can be used as a key toLevelData(Map)
.- See Also:
-
FIELD_UNIT
Represents the unit field name. The field value is available withgetUnit()
. The field type isString
. The constant can be used as a key toLevelData(Map)
.- See Also:
-
-
Constructor Details
-
LevelData
Constructs newLevelData
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 theFIELD_LEVEL
field with 1.FIELD_LEVEL
- mandatory field. The value type must beBigDecimal
.FIELD_UNIT
- optional field. The value type must beString
.
- Parameters:
fields
- Contains the newLevelData
instance field values.- Throws:
ClassCastException
- If the field value types are not expected.IllegalArgumentException
- If the level is missing.NullPointerException
- If the fields map isnull
.
-
LevelData
Constructs newLevelData
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:
NullPointerException
- Iflevel
isnull
.
-
-
Method Details
-
getLevel
ReturnsLevelData
value. The value type isBigDecimal
instead ofdouble
to guarantee value accuracy.- Returns:
- The
LevelData
value.
-
getUnit
- Returns:
- The value unit or
null
if the unit is missing.
-
equals
TwoLevelData
instances are equal if they contain equal metadata, timestamp, unit and level.- Overrides:
equals
in classFunctionData
- Parameters:
o
- The object to compare this data.- Returns:
true
if this object is equivalent to the specified one.- See Also:
-
hashCode
public int hashCode()Returns the hash code for thisLevelData
object. The hash code is a sum ofFunctionData.hashCode()
,String.hashCode()
andBigDecimal.hashCode()
, whereString.hashCode()
represents the unit hash code andBigDecimal.hashCode()
represents the level hash code.- Overrides:
hashCode
in classFunctionData
- Returns:
- The hash code of this
LevelData
object. - See Also:
-
compareTo
Compares thisLevelData
instance with the given argument. If the argument is notLevelData
, it throwsClassCastException
. 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.
- Specified by:
compareTo
in interfaceComparable<Object>
- Overrides:
compareTo
in classFunctionData
- Parameters:
o
-LevelData
to be compared.- Returns:
-1
,0
or1
depending on the comparison rules.- Throws:
ClassCastException
- If the method argument is not of typeLevelData
.- See Also:
-
toString
Returns the string representation of this level data.
-