Java version of the OGC SensorThings API's entity model.
Covers the Sensing part and want to cover the Tasking part when it will be available.
Within the Sensing part, this model is compatible with:
- The Sensing entities
- The SensorThings MultiDatastream extension
The SensorThings Data Array extension(in a future release)
Under submission to Maven Central.
All entities can be constructed via its associated builder
. For instance, a HistoricalLocation can be built like this:
final HistoricalLocation historicalLocation = HistoricalLocation.builder()
.id(new Integer(1))
.selfLink(new URL("http://example.org/v1.0/HistoricalLocations(1)"))
.locationsNavigationLink("HistoricalLocations(1)/Locations")
.thingNavigationLink("HistoricalLocations(1)/Thing")
.time(TMInstant.builder()
.instant(OffsetDateTime.parse("2018-03-28T12:00:00+01:00"))
.build()
)
.build();
More example of entities construction can be found in the unit tests.
All entities supports the use of the Jackson library to allow JSON serialization/deserialization.
In addition, all entities integrates its own Jackson configuration (e.g., specific serializers or deserializers). Hence, only a default Jackson's ObjectMapper instance can be used to manipulate them.
For instance, the basic JSON serialization process of our previous historicalLocation
would be:
final String jsonHistoricalLocation = new ObjectMapper().writeValueAsString(historicalLocation);
That will produce the following JSON file:
{
"@iot.id": 1,
"@iot.selfLink": "http://example.org/v1.0/HistoricalLocations(1)",
"Locations@iot.navigationLink": "HistoricalLocations(1)/Locations",
"Thing@iot.navigationLink": "HistoricalLocations(1)/Thing",
"time": "2015-01-25T12:00:00-07:00"
}
In the same way, the basic JSON deserialization process would be:
final HistoricalLocation deserializedHistoricalLocation = new ObjectMapper().readValue(jsonHistoricalLocation, HistoricalLocation.class);
And, as we expect, the deserializedHistoricalLocation
will be the same as our previous historicalLocation
.
More examples of serialization/deserialization can be found in the unit tests.
Feel free to contribute by making a pull request
following the contributing instructions.