Extending ValueTypes

I want to create new ValueDescriptor types so I can have safer constraints and conversions to these data types: https://github.com/eclipse/tahu/blob/d6552c9f52e96f58b5ca30ccc9d3652861cb0b9c/java/lib/core/src/main/java/org/eclipse/tahu/message/model/MetricDataType.java#L26

My question is can I simply create new descriptors without worrying about how the value will be stored? Since they are all basic data types?

Hi,

There is a big PR pending with updates to the Asset Model but it shouldn’t affect you too much in terms of adding new value types.

You need to create an implmentation of AssetModelProvider and can use auto scanning capability or you can supply your custom ValueDescriptors via the getValueDescriptors().

As for the data types used in the ValueDescriptor if they are just simple types then you can extend the existing ValueDescriptors and add your additional constraints as needed, e.g.:

ValueDescriptor<Double> MY_VALUE_TYPE = ValueType.NUMBER.withConstraints(ValueConstraint.constraints(new ValueConstraint.Min(100), new ValueConstraint.Max(200)));

If you want to use custom data types then just make sure they serialize/deserialize correctly with Jackson.