public class TLcdISO19103MeasureAnnotation extends Object implements ILcdAnnotation
ILcdAnnotation
that associates a certain unit of measure with a type or property.
A typical use-case of this annotation is if the decoded model just contains number values for a certain
property, but you have extra knowledge to associate a unit of measure to that number.
By adding the association, you expose this information to other parties.
For example, a UI can show the unit next to the number which gives meaning to the number for the UI user.
Another example is that it allows to compare values from different models even
if they use a different unit by converting them to a common unit.
Note that this is only possible if the unit of measure applies to all possible
values of the type or property. In case the unit of measure can vary, the
ILcdISO19103Measure
interface should be implemented by the model class representing
that specific type.
TLcdDataModel dataModel = ...;
TLcdDataType streetDataType = ...;
//annotate the field with a UOM, indicating that the field represents a speed
TLcdDataProperty maxSpeedProperty = streetDataType.getProperty("MaxSpeed");
buildingDateProperty.addAnnotation(new TLcdISO19103MeasureAnnotation(TLcdUnitOfMeasureFactory.SPEED_KILOMETRE_HOUR));
ILcdISO19103Measure
instances directly in the data model:
TLcdDataModelBuilder builder = new TLcdDataModelBuilder("http://www.mydomain.com/datamodel/myDataModel");
TLcdDataTypeBuilder speedMeasure = builder.typeBuilder("MaxSpeed").instanceClass(ILcdISO19103Measure.class);
TLcdDataTypeBuilder dataType = builder.typeBuilder("RoadType");
dataType.addProperty("MaxSpeed", speedMeasure).
...
//In this example, the model decoder would store ILcdISO19103Measure instances in the data model:
ILcdDataObject domainObject = ...;
domainObject.setValue("MaxSpeed", new TLcdISO19103Measure(25, TLcdUnitOfMeasureFactory.SPEED_KILOMETRE_HOUR));
Constructor and Description |
---|
TLcdISO19103MeasureAnnotation(ILcdISO19103UnitOfMeasure aUnitOfMeasure)
Constructs an annotation with the given unit of measure.
|
Modifier and Type | Method and Description |
---|---|
ILcdISO19103UnitOfMeasure |
getUnitOfMeasure()
Returns the unit of measure for the annotated property or type.
|
public TLcdISO19103MeasureAnnotation(ILcdISO19103UnitOfMeasure aUnitOfMeasure)
aUnitOfMeasure
- the unit of measure for this annotationpublic ILcdISO19103UnitOfMeasure getUnitOfMeasure()