Class BooleanData
- java.lang.Object
-
- org.osgi.service.dal.FunctionData
-
- org.osgi.service.dal.functions.data.BooleanData
-
- All Implemented Interfaces:
java.lang.Comparable<java.lang.Object>
public class BooleanData extends FunctionData
Function boolean data wrapper. It can contain a boolean value, timestamp and additional metadata. It doesn't support measurement unit.- See Also:
BooleanControl,BooleanSensor,FunctionData
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFIELD_VALUERepresents the value field name.-
Fields inherited from class org.osgi.service.dal.FunctionData
DESCRIPTION, FIELD_METADATA, FIELD_TIMESTAMP
-
-
Constructor Summary
Constructors Constructor Description BooleanData(long timestamp, java.util.Map<java.lang.String,?> metadata, boolean value)Constructs newBooleanDatainstance with the specified arguments.BooleanData(java.util.Map<java.lang.String,?> fields)Constructs newBooleanDatainstance with the specified field values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(java.lang.Object o)Compares thisBooleanDatainstance with the given argument.booleanequals(java.lang.Object o)TwoBooleanDatainstances are equal if they contain equal metadata, timestamp and boolean value.booleangetValue()ReturnsBooleanDatavalue.inthashCode()Returns the hash code for thisBooleanDataobject.java.lang.StringtoString()Returns the string representation of this boolean data.-
Methods inherited from class org.osgi.service.dal.FunctionData
getMetadata, getTimestamp
-
-
-
-
Field Detail
-
FIELD_VALUE
public static final java.lang.String FIELD_VALUE
Represents the value field name. The field value is available withgetValue(). The field type isboolean. The constant can be used as a key toBooleanData(Map).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BooleanData
public BooleanData(java.util.Map<java.lang.String,?> fields)
Constructs newBooleanDatainstance 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: {"value"=Boolean(true)...}. That map will initialize theFIELD_VALUEfield withtrue.FIELD_VALUE- mandatory field. The value type must beBoolean.- Parameters:
fields- Contains the newBooleanDatainstance field values.- Throws:
java.lang.ClassCastException- If the field value types are not expected.java.lang.IllegalArgumentException- If the value is missing.java.lang.NullPointerException- If the fields map isnull.
-
BooleanData
public BooleanData(long timestamp, java.util.Map<java.lang.String,?> metadata, boolean value)Constructs newBooleanDatainstance with the specified arguments.- Parameters:
timestamp- The boolean data timestamp optional field.metadata- The boolean data metadata optional field.value- The boolean value mandatory field.
-
-
Method Detail
-
getValue
public boolean getValue()
ReturnsBooleanDatavalue.- Returns:
BooleanDatavalue.
-
equals
public boolean equals(java.lang.Object o)
TwoBooleanDatainstances are equal if they contain equal metadata, timestamp and boolean value.- Overrides:
equalsin classFunctionData- Parameters:
o- The object to compare this data.- Returns:
trueif this object is equivalent to the specified one.- See Also:
FunctionData.equals(java.lang.Object)
-
hashCode
public int hashCode()
Returns the hash code for thisBooleanDataobject. The hash code is a sum ofFunctionData.hashCode()andBoolean.hashCode(), whereBoolean.hashCode()represents the boolean value hash code.- Overrides:
hashCodein classFunctionData- Returns:
- The hash code of this
BooleanDataobject. - See Also:
FunctionData.hashCode()
-
compareTo
public int compareTo(java.lang.Object o)
Compares thisBooleanDatainstance with the given argument. If the argument is notBooleanData, 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 interfacejava.lang.Comparable<java.lang.Object>- Overrides:
compareToin classFunctionData- Parameters:
o-BooleanDatato be compared.- Returns:
-1,0or1depending on the comparison rules.- Throws:
java.lang.ClassCastException- If the method argument is not of typeBooleanData.- See Also:
Comparable.compareTo(java.lang.Object)
-
toString
public java.lang.String toString()
Returns the string representation of this boolean data.- Overrides:
toStringin classjava.lang.Object- Returns:
- The string representation of this boolean data.
-
-