use of org.eclipse.vorto.core.api.model.datatype.ConstraintIntervalType in project vorto by eclipse.
the class FunctionBlockXmlTemplate method handleRangeEnumeration.
private void handleRangeEnumeration(final Object lwm2mObject, final Property property, final Item item) {
if (property.getConstraintRule() != null) {
final EList<Constraint> constraints = property.getConstraintRule().getConstraints();
final StringBuilder rangeSb = new StringBuilder();
for (final Constraint constraint : constraints) {
final ConstraintIntervalType type = constraint.getType();
final String constraintValues = constraint.getConstraintValues();
if (type == ConstraintIntervalType.MIN) {
rangeSb.append(constraintValues).append('-');
} else if (type == ConstraintIntervalType.MAX) {
rangeSb.append(constraintValues);
} else if (type == ConstraintIntervalType.STRLEN) {
rangeSb.append("0-").append(constraintValues).append(" bytes");
} else {
final String errMsg = unsupportedValueForPropertyMsg("ConstraintIntervalType <" + type + ">", property, lwm2mObject);
throw new IllegalArgumentException(errMsg);
}
}
item.setRangeEnumeration(rangeSb.toString());
}
}
Aggregations