Data
Base class of all collected data, such as a location or a heart rate.
A probe or user task produces a Data object, which is wrapped in a Measurement with a timestamp and uploaded. This base class holds no values itself; subclasses add the fields.
Key points:
- The data type (dataType) is derived from jsonType. By default this is
dk.cachet.carp.<classname in lowercase>, e.g.dk.cachet.carp.geolocationfor Geolocation. - Each subclass must be registered in FromJsonFactory to be deserialized.
- Override equivalentTo to let triggers react to specific data values.
See also SensorData, InputData and the data type names in CarpDataTypes.
- Inheritance
-
- Object
- Serializable
- Data
- Implementers
- Annotations
-
- @JsonSerializable(includeIfNull: false, explicitToJson: true)
Constructors
Data.fromJson
Data
Properties
dataType
The type of this data as a DataType.
fromJsonFunction
The function which can convert a JSON string to an object of this type.
jsonType
Return the __type to be used for JSON serialization of this class. Default is runtimeType. Only specify this if you need another type.
recordId
Stable identifier of the source record, if available; null by default.
Subclasses whose data comes from a store with record ids (e.g., health data) can return it, e.g. to avoid duplicates. Not serialized.
Methods
equivalentTo
Is this data equivalent to other?
This is a custom 'soft' equal (==) operator used to compare two data objects. Used in triggering when some data is collected. Returns false in this base class; override in subclasses to provide custom equivalence checking.
toJson
Return a JSON encoding of this object.