From 468b3dcbd9e2eabeaddf8c5081b28cfa6493721d Mon Sep 17 00:00:00 2001 From: vasraz Date: Wed, 7 Dec 2022 17:05:26 +0000 Subject: [PATCH 1/1] Add support for comparable type constraints for strings Signed-off-by: Vasyl Razinkov Change-Id: I3b52c720968ab8333fa2ec81b13c3d0e7b2f4316 Issue-ID: SDC-4299 --- .../constraints/AbstractComparablePropertyConstraint.java | 4 +--- .../sdc/be/model/tosca/constraints/ConstraintUtil.java | 11 +++-------- 2 files changed, 4 insertions(+), 11 deletions(-) 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: -- 2.16.6