use of de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.ValueFormatException in project FAAAST-Service by FraunhoferIOSB.
the class RangeValueMapper method toValue.
@Override
public RangeValue toValue(Range submodelElement) {
if (submodelElement == null) {
return null;
}
RangeValue rangeValue = new RangeValue();
try {
rangeValue.setMin(TypedValueFactory.create(submodelElement.getValueType(), submodelElement.getMin()));
rangeValue.setMax(TypedValueFactory.create(submodelElement.getValueType(), submodelElement.getMax()));
} catch (ValueFormatException ex) {
// TODO properly throw?
throw new RuntimeException("invalid data value");
}
return rangeValue;
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.ValueFormatException in project FAAAST-Service by FraunhoferIOSB.
the class TypedValueDeserializer method deserialize.
@Override
public TypedValue deserialize(JsonParser parser, DeserializationContext context) throws IOException, JacksonException {
TypeInfo typeInfo = ContextAwareElementValueDeserializer.getTypeInfo(context);
if (typeInfo == null || !ElementValueTypeInfo.class.isAssignableFrom(typeInfo.getClass())) {
throw new RuntimeException("missing datatype information");
}
Datatype datatype = ((ElementValueTypeInfo) typeInfo).getDatatype();
try {
return TypedValueFactory.create(datatype, parser.getValueAsString());
} catch (ValueFormatException ex) {
throw new IOException(String.format("error deserializing typed value (datatype: %s, value %s", datatype.getName(), parser.getValueAsString()), ex);
}
}
Aggregations