Package org.osgi.service.dal
Class FunctionData
java.lang.Object
org.osgi.service.dal.FunctionData
- All Implemented Interfaces:
- Comparable<Object>
- Direct Known Subclasses:
- AlarmData,- BooleanData,- KeypadData,- LevelData
Abstract 
Function data wrapper. A subclass must be used for an access
 to the property values by all functions. It takes care about the timestamp
 and additional metadata. The subclasses are responsible to provide concrete
 value and unit if required.- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionFunctionData(long timestamp, Map<String, ?> metadata) Constructs newFunctionDatainstance with the specified arguments.FunctionData(Map<String, ?> fields) Constructs newFunctionDatainstance with the specified field values.
- 
Method SummaryModifier and TypeMethodDescriptionintCompares thisFunctionDatainstance with the given argument.booleanTwoFunctionDatainstances are equal if their metadata and timestamp are equivalent.ReturnsFunctionDatametadata.longReturnsFunctionDatatimestamp.inthashCode()Returns the hash code of thisFunctionData.
- 
Field Details- 
FIELD_TIMESTAMPRepresents the timestamp field name. The field value is available withgetTimestamp(). The field type islong. The constant can be used as a key toFunctionData(Map).- See Also:
 
- 
FIELD_METADATARepresents the metadata field name. The field value is available withgetMetadata(). The field type isMap. The constant can be used as a key toFunctionData(Map).- See Also:
 
- 
DESCRIPTIONMetadata key, which value represents the data description. The property value type isjava.lang.String.- See Also:
 
 
- 
- 
Constructor Details- 
FunctionDataConstructs newFunctionDatainstance 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: {"timestamp"=Long(1384440775495)}. That map will initialize theFIELD_TIMESTAMPfield with 1384440775495. If timestamp is missing,Long.MIN_VALUEis used.- FIELD_TIMESTAMP- optional field. The value type must be- Long.
- FIELD_METADATA- optional field. The value type must be- Map.
 - Parameters:
- fields- Contains the new- FunctionDatainstance field values.
- Throws:
- ClassCastException- If the field value types are not expected.
- NullPointerException- If the fields map is- null.
 
- 
FunctionDataConstructs newFunctionDatainstance with the specified arguments.- Parameters:
- timestamp- The data timestamp optional field.
- metadata- The data metadata optional field.
 
 
- 
- 
Method Details- 
getTimestamppublic long getTimestamp()ReturnsFunctionDatatimestamp. The timestamp is the difference between the value collecting time and midnight, January 1, 1970 UTC. It's measured in milliseconds. The device driver is responsible to generate that value when the value is received from the device.Long.MIN_VALUEvalue means no timestamp.- Returns:
- FunctionDatatimestamp.
 
- 
getMetadataReturnsFunctionDatametadata. It's dynamic metadata related only to this specific value. Possible keys:- DESCRIPTION
- custom key
 - Returns:
- FunctionDatametadata or- nullis there is no metadata.
 
- 
equalsTwoFunctionDatainstances are equal if their metadata and timestamp are equivalent.
- 
hashCodepublic int hashCode()Returns the hash code of thisFunctionData.
- 
compareToCompares thisFunctionDatainstance with the given argument. If the argument is notFunctionData, it throwsClassCastException. Otherwise, this method returns:- -1if this instance timestamp is less than the argument timestamp. If they are equivalent, it can be the result of the metadata map deep comparison.
- 0if all fields are equivalent.
- 1if this instance timestamp is greater than the argument timestamp. If they are equivalent, it can be the result of the metadata map deep comparison.
 java.util.Mapand array instances.nullis less than any other non-null instance.- Specified by:
- compareToin interface- Comparable<Object>
- Parameters:
- o-- FunctionDatato be compared.
- Returns:
- -1,- 0or- 1depending on the comparison rules.
- Throws:
- ClassCastException- If the method argument is not of type- FunctionDataor metadata maps contain values of different types for the same key.
- NullPointerException- If the method argument is- null.
- See Also:
 
 
-