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
FieldsModifier and TypeFieldDescriptionstatic final StringRepresents the level field name.static final StringRepresents the unit field name.Fields inherited from class org.osgi.service.dal.FunctionData
DESCRIPTION, FIELD_METADATA, FIELD_TIMESTAMP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCompares thisLevelDatainstance with the given argument.booleanTwoLevelDatainstances are equal if they contain equal metadata, timestamp, unit and level.getLevel()ReturnsLevelDatavalue.getUnit()inthashCode()Returns the hash code for thisLevelDataobject.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 newLevelDatainstance 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_LEVELfield with 1.FIELD_LEVEL- mandatory field. The value type must beBigDecimal.FIELD_UNIT- optional field. The value type must beString.
- Parameters:
fields- Contains the newLevelDatainstance 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 newLevelDatainstance 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- Iflevelisnull.
-
-
Method Details
-
getLevel
ReturnsLevelDatavalue. The value type isBigDecimalinstead ofdoubleto guarantee value accuracy.- Returns:
- The
LevelDatavalue.
-
getUnit
- Returns:
- The value unit or
nullif the unit is missing.
-
equals
TwoLevelDatainstances are equal if they contain equal metadata, timestamp, unit and level.- Overrides:
equalsin classFunctionData- Parameters:
o- The object to compare this data.- Returns:
trueif this object is equivalent to the specified one.- See Also:
-
hashCode
public int hashCode()Returns the hash code for thisLevelDataobject. 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:
hashCodein classFunctionData- Returns:
- The hash code of this
LevelDataobject. - See Also:
-
compareTo
Compares thisLevelDatainstance with the given argument. If the argument is notLevelData, it throwsClassCastException. Otherwise, this method returns:-1if this instance field is less than a field of the specified argument.0if all fields are equivalent.1if this instance field is greater than a field of the specified argument.
- Specified by:
compareToin interfaceComparable<Object>- Overrides:
compareToin classFunctionData- Parameters:
o-LevelDatato be compared.- Returns:
-1,0or1depending 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.
-