From: vasraz Date: Wed, 7 Dec 2022 17:05:26 +0000 (+0000) Subject: Add support for comparable type constraints for strings X-Git-Tag: 1.12.1~45 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=468b3dcbd9e2eabeaddf8c5081b28cfa6493721d;hp=16a6ce043bc95c3db4634ebbc955f8a5ea92056d;p=sdc.git Add support for comparable type constraints for strings Signed-off-by: Vasyl Razinkov Change-Id: I3b52c720968ab8333fa2ec81b13c3d0e7b2f4316 Issue-ID: SDC-4299 --- diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java index e7730bd612..d7eb6e69c6 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java @@ -33,9 +33,7 @@ public abstract class AbstractComparablePropertyConstraint extends AbstractPrope } protected void initialize(String rawTextValue, ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException { - // Perform verification that the property type is supported for - - // comparison + // Perform verification that the property type is supported for comparison ConstraintUtil.checkComparableType(propertyType); // Check if the text value is valid for the property type if (propertyType.isValidValue(rawTextValue)) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java index 74a9359f2a..1b9b94eb61 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java @@ -60,20 +60,15 @@ public final class ConstraintUtil { * @throws ConstraintValueDoNotMatchPropertyTypeException if the property type cannot be compared */ public static void checkComparableType(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException { - // The validity of the value is already assured by us with our - - // ToscaType.convert() method - - // here we just want to check that the constraint is not used on - - // unsupported type as boolean + // The validity of the value is already assured by us with our ToscaType.convert() method + // here we just want to check that the constraint is not used on unsupported type as boolean switch (propertyType) { case FLOAT: case INTEGER: case TIMESTAMP: case VERSION: - break; case STRING: + break; case BOOLEAN: throw new ConstraintValueDoNotMatchPropertyTypeException("Constraint is invalid for property type <" + propertyType.toString() + ">"); default: