summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java32
1 files changed, 18 insertions, 14 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
index 516474331b..8756ac4ee2 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
@@ -2419,18 +2419,7 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
}
private PropertyConstraint deserializeConstraint(JsonNode value, Class<? extends PropertyConstraint> constraintClass) {
- JsonNodeType type = value.getNodeType();
- if (type.equals(JsonNodeType.NUMBER)) {
- float asFloat = (float) value.asDouble();
- if ((asFloat % 1) == 0) {
- return deserializeConstraintWithObjectOperand(value.asInt(), constraintClass);
- }
- return deserializeConstraintWithObjectOperand(asFloat, constraintClass);
- } else if (type.equals(JsonNodeType.BOOLEAN)) {
- return deserializeConstraintWithObjectOperand(value.asBoolean(), constraintClass);
- } else {
- return deserializeConstraintWithObjectOperand(value.asText(), constraintClass);
- }
+ return deserializeConstraintWithObjectOperand(convertToType(value), constraintClass);
}
private PropertyConstraint deserializeConstraintWithObjectOperand(Object value, Class<? extends PropertyConstraint> constraintClass) {
@@ -2496,14 +2485,29 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
ValidValuesConstraint vvConstraint = new ValidValuesConstraint();
List<Object> validValues = new ArrayList<>();
for (JsonNode jsonElement : rangeArray) {
- String item = jsonElement.asText();
- validValues.add(item);
+ validValues.add(convertToType(jsonElement));
}
vvConstraint.setValidValues(validValues);
return vvConstraint;
}
return null;
}
+
+ private Object convertToType(JsonNode jsonElement) {
+ if (jsonElement.getNodeType().equals(JsonNodeType.NUMBER)) {
+ float asFloat = (float) jsonElement.asDouble();
+ if ((asFloat % 1) == 0) {
+ return jsonElement.asInt();
+ } else {
+ return asFloat;
+ }
+ } else if (jsonElement.getNodeType().equals(JsonNodeType.BOOLEAN)) {
+ return jsonElement.asBoolean();
+ } else {
+ return jsonElement.asText();
+ }
+ }
+
}