aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractComparablePropertyConstraint.java71
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java27
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraint.java45
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java44
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java208
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java78
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java51
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java54
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java186
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java39
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java58
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java42
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java51
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java51
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java42
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java100
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintFunctionalException.java24
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintRequiredParameterException.java22
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintTechnicalException.java15
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintValueDoNotMatchPropertyTypeException.java22
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintViolationException.java21
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/FunctionalException.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/InvalidPropertyConstraintImplementationException.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/TechnicalException.java14
24 files changed, 574 insertions, 719 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 7b46692253..1611356cc1 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
@@ -20,53 +20,46 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
@SuppressWarnings("rawtypes")
-public abstract class AbstractComparablePropertyConstraint extends AbstractPropertyConstraint implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 2002627754053326321L;
+public abstract class AbstractComparablePropertyConstraint extends AbstractPropertyConstraint {
- private Comparable comparable;
+ private Comparable comparable;
- protected Comparable getComparable() {
- return comparable;
- }
+ protected Comparable getComparable() {
+ return comparable;
+ }
- protected void initialize(String rawTextValue, ToscaType propertyType)
- throws ConstraintValueDoNotMatchPropertyTypeException {
- // 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)) {
- // Convert the raw text value to a comparable value
- comparable = ConstraintUtil.convertToComparable(propertyType, rawTextValue);
- } else {
- // Invalid value throw exception
- throw new ConstraintValueDoNotMatchPropertyTypeException(
- "The value [" + rawTextValue + "] is not valid for the type [" + propertyType + "]");
- }
- }
+ protected void initialize(String rawTextValue, ToscaType propertyType)
+ throws ConstraintValueDoNotMatchPropertyTypeException {
+ // 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)) {
+ // Convert the raw text value to a comparable value
+ comparable = ConstraintUtil.convertToComparable(propertyType, rawTextValue);
+ } else {
+ // Invalid value throw exception
+ throw new ConstraintValueDoNotMatchPropertyTypeException(
+ "The value [" + rawTextValue + "] is not valid for the type [" + propertyType + "]");
+ }
+ }
- protected abstract void doValidate(Object propertyValue) throws ConstraintViolationException;
+ protected abstract void doValidate(Object propertyValue) throws ConstraintViolationException;
- @Override
- public void validate(Object propertyValue) throws ConstraintViolationException {
- if (propertyValue == null) {
- throw new ConstraintViolationException("Value to check is null");
- }
- if (!(comparable.getClass().isAssignableFrom(propertyValue.getClass()))) {
- throw new ConstraintViolationException("Value to check is not comparable to reference type, value type ["
- + propertyValue.getClass() + "], reference type [" + comparable.getClass() + "]");
- }
- doValidate(propertyValue);
- }
+ @Override
+ public void validate(Object propertyValue) throws ConstraintViolationException {
+ if (propertyValue == null) {
+ throw new ConstraintViolationException("Value to check is null");
+ }
+ if (!(comparable.getClass().isAssignableFrom(propertyValue.getClass()))) {
+ throw new ConstraintViolationException("Value to check is not comparable to reference type, value type ["
+ + propertyValue.getClass() + "], reference type [" + comparable.getClass() + "]");
+ }
+ doValidate(propertyValue);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java
index 950a7fa9b9..fc96373d62 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraint.java
@@ -20,27 +20,20 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
import org.openecomp.sdc.be.model.tosca.version.ApplicationVersionException;
-public abstract class AbstractPropertyConstraint implements PropertyConstraint, Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 4459522275459723374L;
+public abstract class AbstractPropertyConstraint implements PropertyConstraint {
- @Override
- public void validate(ToscaType toscaType, String propertyTextValue) throws ConstraintViolationException {
- try {
- validate(toscaType.convert(propertyTextValue));
- } catch (IllegalArgumentException | ApplicationVersionException e) {
- throw new ConstraintViolationException(
- "String value [" + propertyTextValue + "] is not valid for type [" + toscaType + "]", e);
- }
- }
+ @Override
+ public void validate(ToscaType toscaType, String propertyTextValue) throws ConstraintViolationException {
+ try {
+ validate(toscaType.convert(propertyTextValue));
+ } catch (IllegalArgumentException | ApplicationVersionException e) {
+ throw new ConstraintViolationException(
+ "String value [" + propertyTextValue + "] is not valid for type [" + toscaType + "]", e);
+ }
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraint.java
index 142caa2017..8f54c68484 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraint.java
@@ -20,34 +20,27 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-public abstract class AbstractStringPropertyConstraint extends AbstractPropertyConstraint implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 6857605164938136232L;
-
- protected abstract void doValidate(String propertyValue) throws ConstraintViolationException;
-
- @Override
- public void validate(Object propertyValue) throws ConstraintViolationException {
- if (propertyValue == null) {
- throw new ConstraintViolationException("Value to validate is null");
- }
- if (!(propertyValue instanceof String)) {
- throw new ConstraintViolationException("This constraint can only be applied on String value");
- }
- doValidate((String) propertyValue);
- }
-
- @Override
- public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- ConstraintUtil.checkStringType(propertyType);
- }
+public abstract class AbstractStringPropertyConstraint extends AbstractPropertyConstraint {
+
+ protected abstract void doValidate(String propertyValue) throws ConstraintViolationException;
+
+ @Override
+ public void validate(Object propertyValue) throws ConstraintViolationException {
+ if (propertyValue == null) {
+ throw new ConstraintViolationException("Value to validate is null");
+ }
+ if (!(propertyValue instanceof String)) {
+ throw new ConstraintViolationException("This constraint can only be applied on String value");
+ }
+ doValidate((String) propertyValue);
+ }
+
+ @Override
+ public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ ConstraintUtil.checkStringType(propertyType);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java
index 5f19d15293..c78afd8b4a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java
@@ -25,36 +25,36 @@ import java.util.List;
public enum ConstraintType {
- IN_RANGE("inRange"),
+ IN_RANGE("inRange"),
- GREATER_THAN("greaterThan", "greater_than"),
+ GREATER_THAN("greaterThan", "greater_than"),
- GREATER_OR_EQUAL("greaterOrEqual", "greater_or_equal"),
+ GREATER_OR_EQUAL("greaterOrEqual", "greater_or_equal"),
- LESS_OR_EQUAL("lessOrEqual", "less_or_equal"),
+ LESS_OR_EQUAL("lessOrEqual", "less_or_equal"),
- MIN_LENGTH("minLength", "min_length"),
+ MIN_LENGTH("minLength", "min_length"),
- VALID_VALUES("validValues", "valid_values"),
+ VALID_VALUES("validValues", "valid_values"),
- LESS_THAN("lessThan", "less_than");
+ LESS_THAN("lessThan", "less_than");
- List<String> types;
+ List<String> types;
- private ConstraintType(String... types) {
- this.types = Arrays.asList(types);
- }
+ private ConstraintType(String... types) {
+ this.types = Arrays.asList(types);
+ }
- public List<String> getTypes() {
- return types;
- }
+ public List<String> getTypes() {
+ return types;
+ }
- public static ConstraintType getByType(String type) {
- for (ConstraintType inst : ConstraintType.values()) {
- if (inst.getTypes().contains(type)) {
- return inst;
- }
- }
- return null;
- }
+ public static ConstraintType getByType(String type) {
+ for (ConstraintType inst : ConstraintType.values()) {
+ if (inst.getTypes().contains(type)) {
+ return inst;
+ }
+ }
+ return null;
+ }
}
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 79ac5caf25..3c1f0ab711 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
@@ -20,126 +20,126 @@
package org.openecomp.sdc.be.model.tosca.constraints;
+import org.openecomp.sdc.be.model.tosca.ToscaType;
+import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
+
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
-import org.openecomp.sdc.be.model.tosca.ToscaType;
-import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
-
/**
* Utility class to validate constraints types.
*/
public final class ConstraintUtil {
- private ConstraintUtil() {
- }
+ private ConstraintUtil() {
+ }
- /**
- * Validates that the {@link ToscaType} specified is a
- * {@link ToscaType#STRING}.
- *
- * @param propertyType
- * The property tosca type.
- * @throws ConstraintValueDoNotMatchPropertyTypeException
- * In case the type is not {@link ToscaType#STRING}.
- */
- public static void checkStringType(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- if (!ToscaType.STRING.equals(propertyType)) {
- throw new ConstraintValueDoNotMatchPropertyTypeException(
- "Invalid property type <" + propertyType.toString() + ">");
- }
- }
+ /**
+ * Validates that the {@link ToscaType} specified is a
+ * {@link ToscaType#STRING}.
+ *
+ * @param propertyType
+ * The property tosca type.
+ * @throws ConstraintValueDoNotMatchPropertyTypeException
+ * In case the type is not {@link ToscaType#STRING}.
+ */
+ public static void checkStringType(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ if (!ToscaType.STRING.equals(propertyType)) {
+ throw new ConstraintValueDoNotMatchPropertyTypeException(
+ "Invalid property type <" + propertyType.toString() + ">");
+ }
+ }
- /**
- * Verify that the given tosca type is supported for comparison
- *
- * @param propertyType
- * the tosca type to check
- * @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
- switch (propertyType) {
- case FLOAT:
- case INTEGER:
- case TIMESTAMP:
- case VERSION:
- break;
- case STRING:
- case BOOLEAN:
- throw new ConstraintValueDoNotMatchPropertyTypeException(
- "Constraint is invalid for property type <" + propertyType.toString() + ">");
- default:
- throw new ConstraintValueDoNotMatchPropertyTypeException(
- "Invalid property type <" + propertyType.toString() + ">");
- }
- }
+ /**
+ * Verify that the given tosca type is supported for comparison
+ *
+ * @param propertyType
+ * the tosca type to check
+ * @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
+ switch (propertyType) {
+ case FLOAT:
+ case INTEGER:
+ case TIMESTAMP:
+ case VERSION:
+ break;
+ case STRING:
+ case BOOLEAN:
+ throw new ConstraintValueDoNotMatchPropertyTypeException(
+ "Constraint is invalid for property type <" + propertyType.toString() + ">");
+ default:
+ throw new ConstraintValueDoNotMatchPropertyTypeException(
+ "Invalid property type <" + propertyType.toString() + ">");
+ }
+ }
- /**
- * Convert a string value following its type throw exception if it cannot be
- * converted to a comparable
- *
- * @param propertyType
- * the type of the property
- * @param value
- * the value to convert
- * @return the converted comparable
- * @throws ConstraintValueDoNotMatchPropertyTypeException
- * if the converted value is not a comparable
- */
- @SuppressWarnings("rawtypes")
- public static Comparable convertToComparable(ToscaType propertyType, String value)
- throws ConstraintValueDoNotMatchPropertyTypeException {
- Object comparableObj = propertyType.convert(value);
- if (!(comparableObj instanceof Comparable)) {
- throw new IllegalArgumentException(
- "Try to convert a value of a type which is not comparable [" + propertyType + "] to Comparable");
- } else {
- return (Comparable) comparableObj;
- }
- }
+ /**
+ * Convert a string value following its type throw exception if it cannot be
+ * converted to a comparable
+ *
+ * @param propertyType
+ * the type of the property
+ * @param value
+ * the value to convert
+ * @return the converted comparable
+ * @throws ConstraintValueDoNotMatchPropertyTypeException
+ * if the converted value is not a comparable
+ */
+ @SuppressWarnings("rawtypes")
+ public static Comparable convertToComparable(ToscaType propertyType, String value)
+ throws ConstraintValueDoNotMatchPropertyTypeException {
+ Object comparableObj = propertyType.convert(value);
+ if (!(comparableObj instanceof Comparable)) {
+ throw new IllegalArgumentException(
+ "Try to convert a value of a type which is not comparable [" + propertyType + "] to Comparable");
+ } else {
+ return (Comparable) comparableObj;
+ }
+ }
- public static class ConstraintInformation {
- public ConstraintInformation(String name, Object reference, String value, String type) {
+ public static class ConstraintInformation {
+ public ConstraintInformation(String name, Object reference, String value, String type) {
- this.name = name;
- this.reference = reference;
- this.value = value;
- this.type = type;
+ this.name = name;
+ this.reference = reference;
+ this.value = value;
+ this.type = type;
- }
+ }
- private String name;
- private Object reference;
- private String value;
- private String type;
- }
+ private String name;
+ private Object reference;
+ private String value;
+ private String type;
+ }
- public static ConstraintInformation getConstraintInformation(Object constraint) throws IntrospectionException {
- PropertyDescriptor[] propertyDescriptors = Introspector.getBeanInfo(constraint.getClass())
- .getPropertyDescriptors();
- PropertyDescriptor firstDescriptor = null;
- for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
- if (propertyDescriptor.getReadMethod() != null && propertyDescriptor.getWriteMethod() != null) {
- firstDescriptor = propertyDescriptor;
- break;
- }
- }
- if (firstDescriptor == null) {
- throw new IntrospectionException("Cannot find constraint name");
- }
- try {
- return new ConstraintInformation(firstDescriptor.getName(),
- firstDescriptor.getReadMethod().invoke(constraint), null, null);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new IntrospectionException("Cannot retrieve constraint reference " + e.getMessage());
- }
- }
+ public static ConstraintInformation getConstraintInformation(Object constraint) throws IntrospectionException {
+ PropertyDescriptor[] propertyDescriptors = Introspector.getBeanInfo(constraint.getClass())
+ .getPropertyDescriptors();
+ PropertyDescriptor firstDescriptor = null;
+ for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
+ if (propertyDescriptor.getReadMethod() != null && propertyDescriptor.getWriteMethod() != null) {
+ firstDescriptor = propertyDescriptor;
+ break;
+ }
+ }
+ if (firstDescriptor == null) {
+ throw new IntrospectionException("Cannot find constraint name");
+ }
+ try {
+ return new ConstraintInformation(firstDescriptor.getName(),
+ firstDescriptor.getReadMethod().invoke(constraint), null, null);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ throw new IntrospectionException("Cannot retrieve constraint reference " + e.getMessage());
+ }
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
index 530dcb0cc6..7ae64e0ccf 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
@@ -20,58 +20,50 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-//import com.fasterxml.jackson.annotation.JsonIgnore;
+import javax.validation.constraints.NotNull;
-public class EqualConstraint extends AbstractPropertyConstraint implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -1596093341744641483L;
+public class EqualConstraint extends AbstractPropertyConstraint {
- @NotNull
- private String equal;
+ @NotNull
+ private String equal;
- // @JsonIgnore
- private Object typed;
+ // @JsonIgnore
+ private Object typed;
- public EqualConstraint(String equal) {
- super();
- this.equal = equal;
- }
+ public EqualConstraint(String equal) {
+ super();
+ this.equal = equal;
+ }
- @Override
- public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- if (propertyType.isValidValue(equal)) {
- typed = propertyType.convert(equal);
- } else {
- throw new ConstraintValueDoNotMatchPropertyTypeException("equal constraint has invalid value <" + equal
- + "> property type is <" + propertyType.toString() + ">");
- }
- }
+ @Override
+ public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ if (propertyType.isValidValue(equal)) {
+ typed = propertyType.convert(equal);
+ } else {
+ throw new ConstraintValueDoNotMatchPropertyTypeException("equal constraint has invalid value <" + equal
+ + "> property type is <" + propertyType.toString() + ">");
+ }
+ }
- @Override
- public void validate(Object propertyValue) throws ConstraintViolationException {
- if (propertyValue == null) {
- if (typed != null) {
- fail(null);
- }
- } else if (typed == null) {
- fail(propertyValue);
- } else if (!typed.equals(propertyValue)) {
- fail(propertyValue);
- }
- }
+ @Override
+ public void validate(Object propertyValue) throws ConstraintViolationException {
+ if (propertyValue == null) {
+ if (typed != null) {
+ fail(null);
+ }
+ } else if (typed == null) {
+ fail(propertyValue);
+ } else if (!typed.equals(propertyValue)) {
+ fail(propertyValue);
+ }
+ }
- private void fail(Object propertyValue) throws ConstraintViolationException {
- throw new ConstraintViolationException("Equal constraint violation, the reference is <" + equal
- + "> but the value to compare is <" + propertyValue + ">");
- }
+ private void fail(Object propertyValue) throws ConstraintViolationException {
+ throw new ConstraintViolationException("Equal constraint violation, the reference is <" + equal
+ + "> but the value to compare is <" + propertyValue + ">");
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
index 4f2c3ad9ca..63d7ed8872 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
@@ -20,37 +20,30 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-public class GreaterOrEqualConstraint extends AbstractComparablePropertyConstraint implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -5937851077034490609L;
-
- @NotNull
- private String greaterOrEqual;
-
- public GreaterOrEqualConstraint(String greaterOrEqual) {
- super();
- this.greaterOrEqual = greaterOrEqual;
- }
-
- @Override
- public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- initialize(greaterOrEqual, propertyType);
- }
-
- @Override
- protected void doValidate(Object propertyValue) throws ConstraintViolationException {
- if (getComparable().compareTo(propertyValue) > 0) {
- throw new ConstraintViolationException(propertyValue + " <= " + greaterOrEqual);
- }
- }
+import javax.validation.constraints.NotNull;
+
+public class GreaterOrEqualConstraint extends AbstractComparablePropertyConstraint {
+
+ @NotNull
+ private String greaterOrEqual;
+
+ public GreaterOrEqualConstraint(String greaterOrEqual) {
+ this.greaterOrEqual = greaterOrEqual;
+ }
+
+ @Override
+ public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ initialize(greaterOrEqual, propertyType);
+ }
+
+ @Override
+ protected void doValidate(Object propertyValue) throws ConstraintViolationException {
+ if (getComparable().compareTo(propertyValue) > 0) {
+ throw new ConstraintViolationException(propertyValue + " <= " + greaterOrEqual);
+ }
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
index aea2a201ab..b599a16a10 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
@@ -20,47 +20,39 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-public class GreaterThanConstraint extends AbstractComparablePropertyConstraint implements Serializable {
+import javax.validation.constraints.NotNull;
- /**
- *
- */
- private static final long serialVersionUID = 405723215512121896L;
+public class GreaterThanConstraint extends AbstractComparablePropertyConstraint {
- public GreaterThanConstraint(String greaterThan) {
- super();
- this.greaterThan = greaterThan;
- }
+ public GreaterThanConstraint(String greaterThan) {
+ this.greaterThan = greaterThan;
+ }
- @NotNull
- private String greaterThan;
+ @NotNull
+ private String greaterThan;
- @Override
- public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- initialize(greaterThan, propertyType);
- }
+ @Override
+ public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ initialize(greaterThan, propertyType);
+ }
- @Override
- protected void doValidate(Object propertyValue) throws ConstraintViolationException {
- if (getComparable().compareTo(propertyValue) >= 0) {
- throw new ConstraintViolationException(propertyValue + " < " + greaterThan);
- }
- }
+ @Override
+ protected void doValidate(Object propertyValue) throws ConstraintViolationException {
+ if (getComparable().compareTo(propertyValue) >= 0) {
+ throw new ConstraintViolationException(propertyValue + " < " + greaterThan);
+ }
+ }
- public String getGreaterThan() {
- return greaterThan;
- }
+ public String getGreaterThan() {
+ return greaterThan;
+ }
- public void setGreaterThan(String greaterThan) {
- this.greaterThan = greaterThan;
- }
+ public void setGreaterThan(String greaterThan) {
+ this.greaterThan = greaterThan;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
index e8821c2c21..19a2fe4230 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
@@ -20,111 +20,95 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-import java.util.List;
-
-import javax.validation.constraints.NotNull;
-
+import com.google.common.collect.Lists;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-//import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.collect.Lists;
-
-public class InRangeConstraint extends AbstractPropertyConstraint implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -8038401707152824493L;
-
- private List<String> inRange;
-
- private Comparable min;
- private Comparable max;
-
- public InRangeConstraint(List<String> inRange) {
- super();
- this.inRange = inRange;
- }
-
- public InRangeConstraint() {
- super();
- }
-
- @Override
- public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- // Perform verification that the property type is supported for
- // comparison
- ConstraintUtil.checkComparableType(propertyType);
- if (inRange == null || inRange.size() != 2) {
- throw new ConstraintValueDoNotMatchPropertyTypeException("In range constraint must have two elements.");
- }
- String minRawText = inRange.get(0);
- String maxRawText = inRange.get(1);
- if (!propertyType.isValidValue(minRawText)) {
- throw new ConstraintValueDoNotMatchPropertyTypeException("Invalid min value for in range constraint ["
- + minRawText + "] as it does not follow the property type [" + propertyType + "]");
- }
- if (!propertyType.isValidValue(maxRawText)) {
- throw new ConstraintValueDoNotMatchPropertyTypeException("Invalid max value for in range constraint ["
- + maxRawText + "] as it does not follow the property type [" + propertyType + "]");
- }
- min = ConstraintUtil.convertToComparable(propertyType, minRawText);
- max = ConstraintUtil.convertToComparable(propertyType, maxRawText);
- }
-
- @Override
- public void validate(Object propertyValue) throws ConstraintViolationException {
- if (propertyValue == null) {
- throw new ConstraintViolationException("Value to check is null");
- }
- if (!(min.getClass().isAssignableFrom(propertyValue.getClass()))) {
- throw new ConstraintViolationException("Value to check is not comparable to range type, value type ["
- + propertyValue.getClass() + "], range type [" + min.getClass() + "]");
- }
- if (min.compareTo(propertyValue) > 0 || max.compareTo(propertyValue) < 0) {
- throw new ConstraintViolationException("The value [" + propertyValue + "] is out of range " + inRange);
- }
- }
-
- // @JsonProperty
- @NotNull
- public String getRangeMinValue() {
- if (inRange != null) {
- return inRange.get(0);
- } else {
- return null;
- }
- }
-
- // @JsonProperty
- public void setRangeMinValue(String minValue) {
- if (inRange == null) {
- inRange = Lists.newArrayList(minValue, "");
- } else {
- inRange.set(0, minValue);
- }
- }
-
- // @JsonProperty
- @NotNull
- public String getRangeMaxValue() {
- if (inRange != null) {
- return inRange.get(1);
- } else {
- return null;
- }
- }
+import javax.validation.constraints.NotNull;
+import java.util.List;
- // @JsonProperty
- public void setRangeMaxValue(String maxValue) {
- if (inRange == null) {
- inRange = Lists.newArrayList("", maxValue);
- } else {
- inRange.set(1, maxValue);
- }
- }
+public class InRangeConstraint extends AbstractPropertyConstraint {
+
+ private List<String> inRange;
+
+ private Comparable min;
+ private Comparable max;
+
+ public InRangeConstraint(List<String> inRange) {
+ this.inRange = inRange;
+ }
+
+ public InRangeConstraint() { }
+
+ @Override
+ public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ // Perform verification that the property type is supported for
+ // comparison
+ ConstraintUtil.checkComparableType(propertyType);
+ if (inRange == null || inRange.size() != 2) {
+ throw new ConstraintValueDoNotMatchPropertyTypeException("In range constraint must have two elements.");
+ }
+ String minRawText = inRange.get(0);
+ String maxRawText = inRange.get(1);
+ if (!propertyType.isValidValue(minRawText)) {
+ throw new ConstraintValueDoNotMatchPropertyTypeException("Invalid min value for in range constraint ["
+ + minRawText + "] as it does not follow the property type [" + propertyType + "]");
+ }
+ if (!propertyType.isValidValue(maxRawText)) {
+ throw new ConstraintValueDoNotMatchPropertyTypeException("Invalid max value for in range constraint ["
+ + maxRawText + "] as it does not follow the property type [" + propertyType + "]");
+ }
+ min = ConstraintUtil.convertToComparable(propertyType, minRawText);
+ max = ConstraintUtil.convertToComparable(propertyType, maxRawText);
+ }
+
+ @Override
+ public void validate(Object propertyValue) throws ConstraintViolationException {
+ if (propertyValue == null) {
+ throw new ConstraintViolationException("Value to check is null");
+ }
+ if (!(min.getClass().isAssignableFrom(propertyValue.getClass()))) {
+ throw new ConstraintViolationException("Value to check is not comparable to range type, value type ["
+ + propertyValue.getClass() + "], range type [" + min.getClass() + "]");
+ }
+ if (min.compareTo(propertyValue) > 0 || max.compareTo(propertyValue) < 0) {
+ throw new ConstraintViolationException("The value [" + propertyValue + "] is out of range " + inRange);
+ }
+ }
+
+ @NotNull
+ public String getRangeMinValue() {
+ if (inRange != null) {
+ return inRange.get(0);
+ } else {
+ return null;
+ }
+ }
+
+ public void setRangeMinValue(String minValue) {
+ if (inRange == null) {
+ inRange = Lists.newArrayList(minValue, "");
+ } else {
+ inRange.set(0, minValue);
+ }
+ }
+
+ @NotNull
+ public String getRangeMaxValue() {
+ if (inRange != null) {
+ return inRange.get(1);
+ } else {
+ return null;
+ }
+ }
+
+ public void setRangeMaxValue(String maxValue) {
+ if (inRange == null) {
+ inRange = Lists.newArrayList("", maxValue);
+ } else {
+ inRange.set(1, maxValue);
+ }
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
index 2ba0071f2f..c07ac7e2e3 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
@@ -20,35 +20,28 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-public class LengthConstraint extends AbstractStringPropertyConstraint implements Serializable {
+import javax.validation.constraints.NotNull;
- /**
- *
- */
- private static final long serialVersionUID = 6249912030281791233L;
+public class LengthConstraint extends AbstractStringPropertyConstraint {
- @NotNull
- private Integer length;
+ @NotNull
+ private Integer length;
- @Override
- protected void doValidate(String propertyValue) throws ConstraintViolationException {
- if (propertyValue.length() != length) {
- throw new ConstraintViolationException("The length of the value is not equals to [" + length + "]");
- }
- }
+ @Override
+ protected void doValidate(String propertyValue) throws ConstraintViolationException {
+ if (propertyValue.length() != length) {
+ throw new ConstraintViolationException("The length of the value is not equals to [" + length + "]");
+ }
+ }
- public Integer getLength() {
- return length;
- }
+ public Integer getLength() {
+ return length;
+ }
- public void setLength(Integer length) {
- this.length = length;
- }
+ public void setLength(Integer length) {
+ this.length = length;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
index 1491fe327d..7d61dd31df 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
@@ -20,51 +20,39 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-//import alien4cloud.json.deserializer.TextDeserializer;
-//import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-public class LessOrEqualConstraint extends AbstractComparablePropertyConstraint implements Serializable {
+import javax.validation.constraints.NotNull;
- /**
- *
- */
- private static final long serialVersionUID = -4907864317687138678L;
+public class LessOrEqualConstraint extends AbstractComparablePropertyConstraint {
- // @JsonDeserialize(using = TextDeserializer.class)
- @NotNull
- private String lessOrEqual;
+ @NotNull
+ private String lessOrEqual;
- public LessOrEqualConstraint(String lessOrEqual) {
- super();
- this.lessOrEqual = lessOrEqual;
- }
+ public LessOrEqualConstraint(String lessOrEqual) {
+ this.lessOrEqual = lessOrEqual;
+ }
- @Override
- public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- initialize(lessOrEqual, propertyType);
- }
+ @Override
+ public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ initialize(lessOrEqual, propertyType);
+ }
- @Override
- protected void doValidate(Object propertyValue) throws ConstraintViolationException {
- if (getComparable().compareTo(propertyValue) < 0) {
- throw new ConstraintViolationException(propertyValue + " >= " + lessOrEqual);
- }
- }
+ @Override
+ protected void doValidate(Object propertyValue) throws ConstraintViolationException {
+ if (getComparable().compareTo(propertyValue) < 0) {
+ throw new ConstraintViolationException(propertyValue + " >= " + lessOrEqual);
+ }
+ }
- public String getLessOrEqual() {
- return lessOrEqual;
- }
+ public String getLessOrEqual() {
+ return lessOrEqual;
+ }
- public void setLessOrEqual(String lessOrEqual) {
- this.lessOrEqual = lessOrEqual;
- }
+ public void setLessOrEqual(String lessOrEqual) {
+ this.lessOrEqual = lessOrEqual;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
index 2fc43febbf..e2db77b45a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
@@ -20,39 +20,31 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-public class LessThanConstraint extends AbstractComparablePropertyConstraint implements Serializable {
+import javax.validation.constraints.NotNull;
- /**
- *
- */
- private static final long serialVersionUID = 2267623014703859501L;
+public class LessThanConstraint extends AbstractComparablePropertyConstraint {
- @NotNull
- private String lessThan;
+ @NotNull
+ private String lessThan;
- public LessThanConstraint(String lessThan) {
- super();
- this.lessThan = lessThan;
- }
+ public LessThanConstraint(String lessThan) {
+ this.lessThan = lessThan;
+ }
- @Override
- public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- initialize(lessThan, propertyType);
- }
+ @Override
+ public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ initialize(lessThan, propertyType);
+ }
- @Override
- protected void doValidate(Object propertyValue) throws ConstraintViolationException {
- if (getComparable().compareTo(propertyValue) <= 0) {
- throw new ConstraintViolationException(propertyValue + " > " + lessThan);
- }
- }
+ @Override
+ protected void doValidate(Object propertyValue) throws ConstraintViolationException {
+ if (getComparable().compareTo(propertyValue) <= 0) {
+ throw new ConstraintViolationException(propertyValue + " > " + lessThan);
+ }
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
index b6a80afced..8b7ce49cbc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
@@ -20,42 +20,35 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-public class MaxLengthConstraint extends AbstractStringPropertyConstraint implements Serializable {
+import javax.validation.constraints.NotNull;
- /**
- *
- */
- private static final long serialVersionUID = 6377603705670201256L;
+public class MaxLengthConstraint extends AbstractStringPropertyConstraint {
- @NotNull
- private Integer maxLength;
+ @NotNull
+ private Integer maxLength;
- public MaxLengthConstraint(Integer maxLength) {
- this.maxLength = maxLength;
- }
+ public MaxLengthConstraint(Integer maxLength) {
+ this.maxLength = maxLength;
+ }
- public MaxLengthConstraint() {
- super();
- }
+ public MaxLengthConstraint() {
+ super();
+ }
- @Override
- protected void doValidate(String propertyValue) throws ConstraintViolationException {
- if (propertyValue.length() > maxLength) {
- throw new ConstraintViolationException("The length of the value is greater than [" + maxLength + "]");
- }
- }
+ @Override
+ protected void doValidate(String propertyValue) throws ConstraintViolationException {
+ if (propertyValue.length() > maxLength) {
+ throw new ConstraintViolationException("The length of the value is greater than [" + maxLength + "]");
+ }
+ }
- public Integer getMaxLength() {
- return maxLength;
- }
+ public Integer getMaxLength() {
+ return maxLength;
+ }
- public void setMaxLength(Integer maxLength) {
- this.maxLength = maxLength;
- }
+ public void setMaxLength(Integer maxLength) {
+ this.maxLength = maxLength;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java
index f92e5fbb2c..bc51f4fa5a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java
@@ -20,43 +20,36 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-public class MinLengthConstraint extends AbstractStringPropertyConstraint implements Serializable {
+import javax.validation.constraints.NotNull;
- /**
- *
- */
- private static final long serialVersionUID = 32422424680811240L;
+public class MinLengthConstraint extends AbstractStringPropertyConstraint {
- @NotNull
- private Integer minLength;
+ @NotNull
+ private Integer minLength;
- public MinLengthConstraint(Integer minLength) {
- this.minLength = minLength;
- }
+ public MinLengthConstraint(Integer minLength) {
+ this.minLength = minLength;
+ }
- public MinLengthConstraint() {
- super();
- }
+ public MinLengthConstraint() {
+ super();
+ }
- @Override
- protected void doValidate(String propertyValue) throws ConstraintViolationException {
- if (propertyValue.length() < minLength) {
- throw new ConstraintViolationException("The length of the value is less than [" + minLength + "]");
- }
- }
+ @Override
+ protected void doValidate(String propertyValue) throws ConstraintViolationException {
+ if (propertyValue.length() < minLength) {
+ throw new ConstraintViolationException("The length of the value is less than [" + minLength + "]");
+ }
+ }
- public Integer getMinLength() {
- return minLength;
- }
+ public Integer getMinLength() {
+ return minLength;
+ }
- public void setMinLength(Integer minLength) {
- this.minLength = minLength;
- }
+ public void setMinLength(Integer minLength) {
+ this.minLength = minLength;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
index c85c1601e4..db26c33440 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
@@ -20,37 +20,27 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-import java.util.regex.Pattern;
-
-import javax.validation.constraints.NotNull;
-
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-//import com.fasterxml.jackson.annotation.JsonIgnore;
-
-public class PatternConstraint extends AbstractStringPropertyConstraint implements Serializable {
+import javax.validation.constraints.NotNull;
+import java.util.regex.Pattern;
- /**
- *
- */
- private static final long serialVersionUID = 8708185294968697107L;
+public class PatternConstraint extends AbstractStringPropertyConstraint {
- @NotNull
- private String pattern;
+ @NotNull
+ private String pattern;
- // @JsonIgnore
- private Pattern compiledPattern;
+ private Pattern compiledPattern;
- public void setPattern(String pattern) {
- this.pattern = pattern;
- this.compiledPattern = Pattern.compile(this.pattern);
- }
+ public void setPattern(String pattern) {
+ this.pattern = pattern;
+ this.compiledPattern = Pattern.compile(this.pattern);
+ }
- @Override
- protected void doValidate(String propertyValue) throws ConstraintViolationException {
- if (!compiledPattern.matcher(propertyValue).matches()) {
- throw new ConstraintViolationException("The value do not match pattern " + pattern);
- }
- }
+ @Override
+ protected void doValidate(String propertyValue) throws ConstraintViolationException {
+ if (!compiledPattern.matcher(propertyValue).matches()) {
+ throw new ConstraintViolationException("The value do not match pattern " + pattern);
+ }
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
index 738f5150e3..0b35a9be8e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
@@ -20,73 +20,61 @@
package org.openecomp.sdc.be.model.tosca.constraints;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Set;
-
-import javax.validation.constraints.NotNull;
-
+import com.google.common.collect.Sets;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
-//import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.google.common.collect.Sets;
-
-public class ValidValuesConstraint extends AbstractPropertyConstraint implements Serializable {
+import javax.validation.constraints.NotNull;
+import java.util.List;
+import java.util.Set;
- /**
- *
- */
- private static final long serialVersionUID = 5906087180079892853L;
+public class ValidValuesConstraint extends AbstractPropertyConstraint {
- @NotNull
- private List<String> validValues;
- // @JsonIgnore
- private Set<Object> validValuesTyped;
+ @NotNull
+ private List<String> validValues;
+ private Set<Object> validValuesTyped;
- public ValidValuesConstraint(List<String> validValues) {
- super();
- this.validValues = validValues;
- }
+ public ValidValuesConstraint(List<String> validValues) {
+ this.validValues = validValues;
+ }
- public ValidValuesConstraint() {
- super();
- }
+ public ValidValuesConstraint() {
+ }
- @Override
- public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
- validValuesTyped = Sets.newHashSet();
- if (validValues == null) {
- throw new ConstraintValueDoNotMatchPropertyTypeException(
- "validValues constraint has invalid value <> property type is <" + propertyType.toString() + ">");
- }
- for (String value : validValues) {
- if (!propertyType.isValidValue(value)) {
- throw new ConstraintValueDoNotMatchPropertyTypeException("validValues constraint has invalid value <"
- + value + "> property type is <" + propertyType.toString() + ">");
- } else {
- validValuesTyped.add(propertyType.convert(value));
- }
- }
- }
+ @Override
+ public void initialize(ToscaType propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
+ validValuesTyped = Sets.newHashSet();
+ if (validValues == null) {
+ throw new ConstraintValueDoNotMatchPropertyTypeException(
+ "validValues constraint has invalid value <> property type is <" + propertyType.toString() + ">");
+ }
+ for (String value : validValues) {
+ if (!propertyType.isValidValue(value)) {
+ throw new ConstraintValueDoNotMatchPropertyTypeException("validValues constraint has invalid value <"
+ + value + "> property type is <" + propertyType.toString() + ">");
+ } else {
+ validValuesTyped.add(propertyType.convert(value));
+ }
+ }
+ }
- @Override
- public void validate(Object propertyValue) throws ConstraintViolationException {
- if (propertyValue == null) {
- throw new ConstraintViolationException("Value to validate is null");
- }
- if (!validValuesTyped.contains(propertyValue)) {
- throw new ConstraintViolationException("The value is not in the list of valid values");
- }
- }
+ @Override
+ public void validate(Object propertyValue) throws ConstraintViolationException {
+ if (propertyValue == null) {
+ throw new ConstraintViolationException("Value to validate is null");
+ }
+ if (!validValuesTyped.contains(propertyValue)) {
+ throw new ConstraintViolationException("The value is not in the list of valid values");
+ }
+ }
- public List<String> getValidValues() {
- return validValues;
- }
+ public List<String> getValidValues() {
+ return validValues;
+ }
- public void setValidValues(List<String> validValues) {
- this.validValues = validValues;
- }
+ public void setValidValues(List<String> validValues) {
+ this.validValues = validValues;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintFunctionalException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintFunctionalException.java
index c4237e9bcb..a29bb01074 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintFunctionalException.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintFunctionalException.java
@@ -30,21 +30,19 @@ import org.openecomp.sdc.be.model.tosca.constraints.ConstraintUtil.ConstraintInf
*/
public class ConstraintFunctionalException extends FunctionalException {
- private static final long serialVersionUID = 1L;
+ protected final transient ConstraintInformation constraintInformation;
- protected ConstraintInformation constraintInformation;
+ public ConstraintFunctionalException(String message, Throwable cause) {
+ this(message, cause, null);
+ }
- public ConstraintFunctionalException(String message, Throwable cause) {
- super(message, cause);
- }
+ public ConstraintFunctionalException(String message) {
+ this(message, null, null);
+ }
- public ConstraintFunctionalException(String message) {
- super(message);
- }
-
- public ConstraintFunctionalException(String message, Throwable cause, ConstraintInformation constraintInformation) {
- super(message, cause);
- this.constraintInformation = constraintInformation;
- }
+ public ConstraintFunctionalException(String message, Throwable cause, ConstraintInformation constraintInformation) {
+ super(message, cause);
+ this.constraintInformation = constraintInformation;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintRequiredParameterException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintRequiredParameterException.java
index 338e4aa51a..5c97a477c6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintRequiredParameterException.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintRequiredParameterException.java
@@ -30,20 +30,16 @@ import org.openecomp.sdc.be.model.tosca.constraints.ConstraintUtil.ConstraintInf
*/
public class ConstraintRequiredParameterException extends ConstraintFunctionalException {
- private static final long serialVersionUID = 1L;
+ public ConstraintRequiredParameterException(String message) {
+ super(message);
+ }
- public ConstraintRequiredParameterException(String message) {
- super(message);
- }
+ public ConstraintRequiredParameterException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public ConstraintRequiredParameterException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ConstraintRequiredParameterException(String message, Throwable cause,
- ConstraintInformation constraintInformation) {
- super(message, cause);
- this.constraintInformation = constraintInformation;
- }
+ public ConstraintRequiredParameterException(String message, Throwable cause, ConstraintInformation constraintInformation) {
+ super(message, cause, constraintInformation);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintTechnicalException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintTechnicalException.java
index 3816ac61dd..f669e8429b 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintTechnicalException.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintTechnicalException.java
@@ -28,14 +28,11 @@ package org.openecomp.sdc.be.model.tosca.constraints.exception;
*/
public class ConstraintTechnicalException extends Exception {
- private static final long serialVersionUID = 5829360730980521567L;
-
- public ConstraintTechnicalException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ConstraintTechnicalException(String message) {
- super(message);
- }
+ public ConstraintTechnicalException(String message, Throwable cause) {
+ super(message, cause);
+ }
+ public ConstraintTechnicalException(String message) {
+ super(message);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintValueDoNotMatchPropertyTypeException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintValueDoNotMatchPropertyTypeException.java
index 10d4e44fe2..4adefb96de 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintValueDoNotMatchPropertyTypeException.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintValueDoNotMatchPropertyTypeException.java
@@ -30,19 +30,15 @@ import org.openecomp.sdc.be.model.tosca.constraints.ConstraintUtil.ConstraintInf
*/
public class ConstraintValueDoNotMatchPropertyTypeException extends ConstraintFunctionalException {
- private static final long serialVersionUID = 4342613849660957651L;
+ public ConstraintValueDoNotMatchPropertyTypeException(String message) {
+ super(message);
+ }
- public ConstraintValueDoNotMatchPropertyTypeException(String message) {
- super(message);
- }
+ public ConstraintValueDoNotMatchPropertyTypeException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public ConstraintValueDoNotMatchPropertyTypeException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ConstraintValueDoNotMatchPropertyTypeException(String message, Throwable cause,
- ConstraintInformation constraintInformation) {
- super(message, cause);
- this.constraintInformation = constraintInformation;
- }
+ public ConstraintValueDoNotMatchPropertyTypeException(String message, Throwable cause, ConstraintInformation constraintInformation) {
+ super(message, cause, constraintInformation);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintViolationException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintViolationException.java
index 29db0aa1af..3101b7b521 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintViolationException.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/ConstraintViolationException.java
@@ -30,19 +30,16 @@ import org.openecomp.sdc.be.model.tosca.constraints.ConstraintUtil.ConstraintInf
*/
public class ConstraintViolationException extends ConstraintFunctionalException {
- private static final long serialVersionUID = 1L;
+ public ConstraintViolationException(String message) {
+ super(message);
+ }
- public ConstraintViolationException(String message) {
- super(message);
- }
+ public ConstraintViolationException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public ConstraintViolationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ConstraintViolationException(String message, Throwable cause, ConstraintInformation constraintInformation) {
- super(message, cause);
- this.constraintInformation = constraintInformation;
- }
+ public ConstraintViolationException(String message, Throwable cause, ConstraintInformation constraintInformation) {
+ super(message, cause, constraintInformation);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/FunctionalException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/FunctionalException.java
index 1454306e89..4ffc5f030b 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/FunctionalException.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/FunctionalException.java
@@ -29,13 +29,11 @@ package org.openecomp.sdc.be.model.tosca.constraints.exception;
*/
public class FunctionalException extends Exception {
- private static final long serialVersionUID = 6712845685798792493L;
+ public FunctionalException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public FunctionalException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public FunctionalException(String message) {
- super(message);
- }
+ public FunctionalException(String message) {
+ super(message);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/InvalidPropertyConstraintImplementationException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/InvalidPropertyConstraintImplementationException.java
index 2b231d98e3..f4d920bea2 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/InvalidPropertyConstraintImplementationException.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/InvalidPropertyConstraintImplementationException.java
@@ -28,13 +28,11 @@ package org.openecomp.sdc.be.model.tosca.constraints.exception;
*/
public class InvalidPropertyConstraintImplementationException extends ConstraintTechnicalException {
- private static final long serialVersionUID = 2797550944328544706L;
+ public InvalidPropertyConstraintImplementationException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public InvalidPropertyConstraintImplementationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidPropertyConstraintImplementationException(String message) {
- super(message);
- }
+ public InvalidPropertyConstraintImplementationException(String message) {
+ super(message);
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/TechnicalException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/TechnicalException.java
index 1bddeea69b..5d369a08a4 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/TechnicalException.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/exception/TechnicalException.java
@@ -28,13 +28,11 @@ package org.openecomp.sdc.be.model.tosca.constraints.exception;
*/
public abstract class TechnicalException extends RuntimeException {
- private static final long serialVersionUID = -9152473183025390161L;
+ public TechnicalException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public TechnicalException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public TechnicalException(String message) {
- super(message);
- }
+ public TechnicalException(String message) {
+ super(message);
+ }
}