Change Log 0.8.1
Version 0.8.1 aligns the Digital Twin State with the Physical Asset Description: properties, events and actions now carry both a semantic type and a contentType (the format) in the State too.
Key updates:
contentTypein the DT State —DigitalTwinStatePropertyandDigitalTwinStateEventgain acontentTypefield (DigitalTwinStateActionalready had it)- New constructors that set both
typeandcontentType - Constructors with only the
typeare deprecated and will not be supported anymore from version 0.9.0 equals/hashCode/toStringof the State and Physical resources now includetypeandcontentType; severalNullPointerExceptioninequalsare fixed
No behaviour of the framework changes: the core never interprets type or contentType, it only stores and forwards them (state changes, state copies, observers), so existing code keeps compiling and running (with deprecation warnings).
Semantics
| Field | Meaning | Example |
|---|---|---|
type | Semantic type: what the resource represents, typically from an ontology or from the application domain | iot.demo.accelerometer |
contentType | Format used to represent the value (property), the body of the notifications (event) or the input (action) | string, application/json, java.lang.Double |
A string that comes from the accelerometer of a specific device has type = "iot.demo.accelerometer" and contentType = "string".
The core does not know MIME types: both fields are plain strings, and it is up to the application (e.g., DigiWave) to give them a meaning.
API changes
DigitalTwinStateProperty<T>
| Constructor | Status |
|---|---|
(key, value, type, contentType) | New |
(key, value, type, contentType, readable, writable, exposed) | New |
(key, value, type) | Deprecated, removed in 0.9.0. contentType = Class name of the value |
(key, value), (key, value, readable, writable[, exposed]) | Unchanged. type and contentType = Class name of the value |
New accessors: getContentType() and setContentType(String).
If type or contentType are null they default to the name of the Class of the value (same default as PhysicalAssetProperty.contentType).
DigitalTwinStateEvent
| Constructor | Status |
|---|---|
(key, type, contentType) | New |
(key, type) | Deprecated, removed in 0.9.0. contentType = null |
New accessors: getContentType() and setContentType(String).
DigitalTwinStateAction
No API change (it already had key, type, contentType). Javadoc aligned: type is semantic, contentType is the format of the input.
Physical Asset Description
| Class | Change |
|---|---|
PhysicalAssetProperty | (key, type, initialValue) is deprecated (removed in 0.9.0). Use (key, type, contentType, initialValue[, immutable, writable]) |
PhysicalAssetEvent | (key, type) is deprecated (removed in 0.9.0). Use (key, type, contentType) |
PhysicalAssetAction | No change |
Before / after
// 0.8.0
dtState.registerEvent(new DigitalTwinStateEvent(event.getKey(), event.getType()));
dtState.createProperty(new DigitalTwinStateProperty<>(property.getKey(), property.getInitialValue()));
// 0.8.1: the semantic type and the format of the Physical Asset Description are copied in the State
dtState.registerEvent(new DigitalTwinStateEvent(event.getKey(), event.getType(), event.getContentType()));
dtState.createProperty(new DigitalTwinStateProperty<>(
property.getKey(), property.getInitialValue(), property.getType(), property.getContentType()));
DigitalTwinStateProperty<String> accelerometer =
new DigitalTwinStateProperty<>("accelerometer", "1.2,0.4,9.8", "iot.demo.accelerometer", "string");
accelerometer.getType(); // "iot.demo.accelerometer"
accelerometer.getContentType(); // "string"
Updating a property
updatePropertyValue(...) changes only the value and keeps type and contentType.
updateProperty(...) replaces the whole property: a property built with new DigitalTwinStateProperty<>(key, value) resets both fields to the Class name of the value. When only the value changes, use updatePropertyValue(...) (the examples of docs/getting_started.md have been updated).
Fixes
PhysicalAssetEvent.equalsthrewNullPointerExceptionwhencontentTypewasnull, which is exactly what the(key, type)constructor sets.DigitalTwinStateEvent.equalsandPhysicalAssetAction.equals/DigitalTwinStateAction.equalsnow useObjects.equals(noNullPointerExceptionwithnullfields).DigitalTwinStateEvent.toStringprintedPhysicalAssetEvent{...}.PhysicalAssetProperty.equals/hashCodeignoredtypeandcontentType;DigitalTwinStateProperty.hashCodeignoredtype. They are now consistent withequals.
Migration to 0.9.0
- Replace every
new DigitalTwinStateProperty<>(key, value, type)with the constructor that also sets thecontentType. - Replace every
new DigitalTwinStateEvent(key, type)withnew DigitalTwinStateEvent(key, type, contentType). - Replace
new PhysicalAssetProperty<>(key, type, value)andnew PhysicalAssetEvent(key, type)the same way. - When creating State resources from a Physical Asset Description, copy
getType()andgetContentType().
The compiler reports the remaining usages as deprecation warnings (-Xlint:deprecation).