public abstract class FunctionData extends Object implements Comparable<Object>
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.Modifier and Type | Field and Description |
---|---|
static String |
DESCRIPTION
Metadata key, which value represents the data description.
|
static String |
FIELD_METADATA
Represents the metadata field name.
|
static String |
FIELD_TIMESTAMP
Represents the timestamp field name.
|
Constructor and Description |
---|
FunctionData(long timestamp,
Map<String,?> metadata)
Constructs new
FunctionData instance with the specified
arguments. |
FunctionData(Map<String,?> fields)
Constructs new
FunctionData instance with the specified field
values. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Object o)
Compares this
FunctionData instance with the given argument. |
boolean |
equals(Object other)
Two
FunctionData instances are equal if their metadata and
timestamp are equivalent. |
Map<String,?> |
getMetadata()
Returns
FunctionData metadata. |
long |
getTimestamp()
Returns
FunctionData timestamp. |
int |
hashCode()
Returns the hash code of this
FunctionData . |
public static final String FIELD_TIMESTAMP
getTimestamp()
. The field type is long
. The constant can
be used as a key to FunctionData(Map)
.public static final String FIELD_METADATA
getMetadata()
. The field type is Map
. The constant can
be used as a key to FunctionData(Map)
.public static final String DESCRIPTION
java.lang.String
.public FunctionData(Map<String,?> fields)
FunctionData
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: {"timestamp"=Long(1384440775495)}. That map will initialize the
FIELD_TIMESTAMP
field with 1384440775495. If timestamp is
missing, Long.MIN_VALUE
is used.
FIELD_TIMESTAMP
- optional field. The value type must be
Long
.FIELD_METADATA
- optional field. The value type must be
Map
.fields
- Contains the new FunctionData
instance field
values.ClassCastException
- If the field value types are not expected.NullPointerException
- If the fields map is null
.public long getTimestamp()
FunctionData
timestamp. 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_VALUE
value means no timestamp.FunctionData
timestamp.public Map<String,?> getMetadata()
FunctionData
metadata. It's dynamic metadata related only
to this specific value. Possible keys:
DESCRIPTION
FunctionData
metadata or null
is there is no
metadata.public boolean equals(Object other)
FunctionData
instances are equal if their metadata and
timestamp are equivalent.equals
in class Object
other
- The other instance to compare. It must be of
FunctionData
type.true
if this instance and argument have equivalent
metadata and timestamp, false
otherwise.Object.equals(java.lang.Object)
public int hashCode()
FunctionData
.hashCode
in class Object
FunctionData
hash code.Object.hashCode()
public int compareTo(Object o)
FunctionData
instance with the given argument. If
the argument is not FunctionData
, it throws
ClassCastException
. Otherwise, this method returns:
-1
if this instance timestamp is less than the argument
timestamp. If they are equivalent, it can be the result of the metadata
map deep comparison.0
if all fields are equivalent.1
if 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.Map
and array instances. null
is less than any
other non-null instance.compareTo
in interface Comparable<Object>
o
- FunctionData
to be compared.-1
, 0
or 1
depending on the comparison
rules.ClassCastException
- If the method argument is not of type
FunctionData
or metadata maps contain values of different
types for the same key.NullPointerException
- If the method argument is null
.Comparable.compareTo(java.lang.Object)
Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0