Class FunctionData

java.lang.Object
org.osgi.service.dal.FunctionData
All Implemented Interfaces:
Comparable<Object>
Direct Known Subclasses:
AlarmData, BooleanData, KeypadData, LevelData

public abstract class FunctionData extends Object implements Comparable<Object>
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 Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Metadata key, which value represents the data description.
    static final String
    Represents the metadata field name.
    static final String
    Represents the timestamp field name.
  • Constructor Summary

    Constructors
    Constructor
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares this FunctionData instance with the given argument.
    boolean
    equals(Object other)
    Two FunctionData instances are equal if their metadata and timestamp are equivalent.
    Returns FunctionData metadata.
    long
    Returns FunctionData timestamp.
    int
    Returns the hash code of this FunctionData.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • FunctionData

      public FunctionData(Map<String,?> fields)
      Constructs new 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.
      Parameters:
      fields - Contains the new FunctionData instance field values.
      Throws:
      ClassCastException - If the field value types are not expected.
      NullPointerException - If the fields map is null.
    • FunctionData

      public FunctionData(long timestamp, Map<String,?> metadata)
      Constructs new FunctionData instance with the specified arguments.
      Parameters:
      timestamp - The data timestamp optional field.
      metadata - The data metadata optional field.
  • Method Details

    • getTimestamp

      public long getTimestamp()
      Returns 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.
      Returns:
      FunctionData timestamp.
    • getMetadata

      public Map<String,?> getMetadata()
      Returns FunctionData metadata. It's dynamic metadata related only to this specific value. Possible keys:
      Returns:
      FunctionData metadata or null is there is no metadata.
    • equals

      public boolean equals(Object other)
      Two FunctionData instances are equal if their metadata and timestamp are equivalent.
      Overrides:
      equals in class Object
      Parameters:
      other - The other instance to compare. It must be of FunctionData type.
      Returns:
      true if this instance and argument have equivalent metadata and timestamp, false otherwise.
      See Also:
    • hashCode

      public int hashCode()
      Returns the hash code of this FunctionData.
      Overrides:
      hashCode in class Object
      Returns:
      FunctionData hash code.
      See Also:
    • compareTo

      public int compareTo(Object o)
      Compares this 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.
      Metadata map deep comparison compares the elements of all nested java.util.Map and array instances. null is less than any other non-null instance.
      Specified by:
      compareTo in interface Comparable<Object>
      Parameters:
      o - FunctionData to be compared.
      Returns:
      -1, 0 or 1 depending on the comparison rules.
      Throws:
      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.
      See Also: