Top Description Fields Constructors Methods
org.osgi.service.dal.functions.data

public Class LevelData

extends FunctionData
Class Inheritance
Imports
java.math.BigDecimal, java.util.Map, org.osgi.service.dal.FunctionData, .PropertyMetadata, org.osgi.service.dal.functions.Meter, .MultiLevelControl, .MultiLevelSensor

Function level data wrapper. It supports all properties defined in FunctionData.
See Also
MultiLevelControl, MultiLevelSensor, Meter, FunctionData

Field Summary

Modifier and TypeField and Description
public static final String
FIELD_LEVEL

Represents the level field name.

public static final String
FIELD_UNIT

Represents the unit field name.

private final BigDecimal
private final String
Inherited from org.osgi.service.dal.FunctionData:
DESCRIPTIONFIELD_METADATAFIELD_TIMESTAMP

Constructor Summary

AccessConstructor and Description
public
LevelData(Map<String, ?>
Contains the new LevelData instance field values.
fields
)

Constructs new LevelData instance with the specified field values.

public
LevelData(long
The data timestamp optional field.
timestamp
,
Map<String, Object>
The data metadata optional field.
metadata
,
BigDecimal
The level value mandatory field.
level
,
String
The data unit optional field.
unit
)

Constructs new LevelData instance with the specified arguments.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

-1, 0 or 1 depending on the comparison rules.
compareTo
(Object
LevelData to be compared.
o
)

Overrides org.osgi.service.dal.FunctionData.compareTo.

Implements java.lang.Comparable.compareTo.

Compares this LevelData instance with the given argument.

public boolean

Returns:

true if this object is equivalent to the specified one.
equals
(Object
The object to compare this data.
o
)

Overrides org.osgi.service.dal.FunctionData.equals.

Two LevelData instances are equal if they contain equal metadata, timestamp, unit and level.

public BigDecimal

Returns:

The LevelData value.
getLevel
()

Returns LevelData value.

public String

Returns:

The value unit or null if the unit is missing.
getUnit
()

Returns LevelData unit as it's specified in PropertyMetadata#UNITS or null if the unit is missing.

public int

Returns:

The hash code of this LevelData object.
hashCode
()

Overrides org.osgi.service.dal.FunctionData.hashCode.

Returns the hash code for this LevelData object.

public String

Returns:

The string representation of this level data.
toString
()

Overrides java.lang.Object.toString.

Returns the string representation of this level data.

Inherited from org.osgi.service.dal.FunctionData:
getMetadatagetTimestamp

Field Detail

FIELD_LEVELback to summary
public static final 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).

FIELD_UNITback to summary
public static final 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).

levelback to summary
private final BigDecimal level
unitback to summary
private final String unit

Constructor Detail

LevelDataback to summary
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.
Parameters
fields:Map<String, ?>

Contains the new LevelData instance field values.

Exceptions
ClassCastException:
If the field value types are not expected.
IllegalArgumentException:
If the level is missing.
NullPointerException:
If the fields map is null.
LevelDataback to summary
public LevelData(long timestamp, Map<String, Object> metadata, BigDecimal level, String unit)

Constructs new LevelData instance with the specified arguments.

Parameters
timestamp:long

The data timestamp optional field.

metadata:Map<String, Object>

The data metadata optional field.

level:BigDecimal

The level value mandatory field.

unit:String

The data unit optional field.

Exceptions
NullPointerException:
If level is null.

Method Detail

compareToback to summary
public int compareTo(Object o)

Overrides org.osgi.service.dal.FunctionData.compareTo.

Implements java.lang.Comparable.compareTo.

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.
Parameters
o:Object

LevelData to be compared.

Returns:int

-1, 0 or 1 depending on the comparison rules.

Annotations
@Override
Exceptions
ClassCastException:
If the method argument is not of type LevelData.
See Also
java.lang.Comparable#compareTo(java.lang.Object)
equalsback to summary
public boolean equals(Object o)

Overrides org.osgi.service.dal.FunctionData.equals.

Two LevelData instances are equal if they contain equal metadata, timestamp, unit and level.

Parameters
o:Object

The object to compare this data.

Returns:boolean

true if this object is equivalent to the specified one.

Annotations
@Override
See Also
org.osgi.service.dal.FunctionData#equals(java.lang.Object)
getLevelback to summary
public BigDecimal getLevel()

Returns LevelData value. The value type is BigDecimal instead of double to guarantee value accuracy.

Returns:BigDecimal

The LevelData value.

getUnitback to summary
public String getUnit()

Returns LevelData unit as it's specified in PropertyMetadata#UNITS or null if the unit is missing.

Returns:String

The value unit or null if the unit is missing.

hashCodeback to summary
public int hashCode()

Overrides org.osgi.service.dal.FunctionData.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.

Returns:int

The hash code of this LevelData object.

Annotations
@Override
See Also
org.osgi.service.dal.FunctionData#hashCode()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the string representation of this level data.

Returns:String

The string representation of this level data.

Annotations
@Override