X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Futil%2FBaseConstraints.java;h=4283ae5aeb77ed774463f80e472c8e0f26f8e125;hb=635af1cfca70d0be0192f997c155d80cbbc5ba5d;hp=7dd5fb402934afbb3caad6913c409e587caf1a59;hpb=06318ba0f909fdb0b8ffd26b0e89708ee2d21ce3;p=yangtools.git
diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseConstraints.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseConstraints.java
index 7dd5fb4029..4283ae5aeb 100644
--- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseConstraints.java
+++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseConstraints.java
@@ -7,28 +7,26 @@
*/
package org.opendaylight.yangtools.yang.model.util;
+import com.google.common.base.Optional;
import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
-import com.google.common.base.Optional;
-
/**
* Utility class which provides factory methods to construct Constraints.
*
* Provides static factory methods which constructs instances of
*
- * - {@link LengthConstraint} - {@link #lengthConstraint(Number, Number, String, String)}
- *
- {@link RangeConstraint} - {@link #rangeConstraint(Number, Number, String, String)}
- *
- {@link PatternConstraint} - {@link #patternConstraint(String, String, String)}
+ *
- {@link LengthConstraint} - {@link #newLengthConstraint(Number, Number, Optional, Optional)}
+ *
- {@link RangeConstraint} - {@link #newRangeConstraint(Number, Number, Optional, Optional)}
+ *
- {@link PatternConstraint} - {@link #newPatternConstraint(String, Optional, Optional)}
*
*/
public final class BaseConstraints {
-
private BaseConstraints() {
+ throw new UnsupportedOperationException();
}
-
/**
* Creates a {@link LengthConstraint}.
*
@@ -37,7 +35,7 @@ public final class BaseConstraints {
*
*
* - {@link LengthConstraint#getErrorAppTag()} returns
length-out-of-specified-bounds
- * - {@link LengthConstraint#getErrorMessage() returns
The argument is out of bounds <min, max >
+ * - {@link LengthConstraint#getErrorMessage()} returns
The argument is out of bounds <min, max >
*
*
* @see LengthConstraint
@@ -54,129 +52,130 @@ public final class BaseConstraints {
}
/**
- * Creates a {@link RangeConstraint}.
+ * Creates a {@link LengthConstraint}.
*
- * Creates an instance of Range constraint based on supplied parameters
+ * Creates an instance of Length constraint based on supplied parameters
* with additional behaviour:
*
*
- * - {@link RangeConstraint#getErrorAppTag()} returns
range-out-of-specified-bounds
- * - {@link RangeConstraint#getErrorMessage() returns
The argument is out of bounds <min, max >
+ * - {@link LengthConstraint#getErrorAppTag()} returns
length-out-of-specified-bounds
+ * - {@link LengthConstraint#getErrorMessage()} returns
The argument is out of bounds <min, max >
*
*
+ * @see LengthConstraint
*
- * @see RangeConstraint
- *
- * @param min value-restricting lower bound value. The value MUST NOT Be null.
- * @param max value-restricting upper bound value. The value MUST NOT Be null.
+ * @param min length-restricting lower bound value. The value MUST NOT be negative.
+ * @param max length-restricting upper bound value. The value MUST NOT be negative.
* @param description Description associated with constraint. {@link Optional#absent()} if description is undefined.
* @param reference Reference associated with constraint. {@link Optional#absent()} if reference is undefined.
- * @return Instance of {@link RangeConstraint}
+ * @param errorAppTag error-app-tag associated with constraint.
+ * @param errorMessage error message associated with constraint.
+ * @return Instance of {@link LengthConstraint}
*/
- public static RangeConstraint newRangeConstraint(final Number min, final Number max, final Optional description,
- final Optional reference) {
- return new RangeConstraintImpl(min, max, description, reference);
+ public static LengthConstraint newLengthConstraint(final Number min, final Number max,
+ final Optional description, final Optional reference, final String errorAppTag,
+ final String errorMessage) {
+ return new LengthConstraintImpl(min, max, description, reference, errorAppTag, errorMessage);
}
-
/**
- * Creates a {@link PatternConstraint}.
+ * Creates a {@link RangeConstraint}.
*
- * Creates an instance of Pattern constraint based on supplied parameters
+ * Creates an instance of Range constraint based on supplied parameters
* with additional behaviour:
*
*
- * - {@link PatternConstraint#getErrorAppTag()} returns
invalid-regular-expression
+ * - {@link RangeConstraint#getErrorAppTag()} returns
range-out-of-specified-bounds
+ * - {@link RangeConstraint#getErrorMessage()} returns
The argument is out of bounds <min, max >
*
*
- * @see PatternConstraint
*
- * @param pattern Regular expression, MUST NOT BE null.
- * @param description Description associated with constraint.
- * @param reference Reference associated with constraint.
- * @returnInstance of {@link PatternConstraint}
+ * @see RangeConstraint
+ *
+ * @param Type of constraint
+ * @param min value-restricting lower bound value. The value MUST NOT Be null.
+ * @param max value-restricting upper bound value. The value MUST NOT Be null.
+ * @param description Description associated with constraint. {@link Optional#absent()} if description is undefined.
+ * @param reference Reference associated with constraint. {@link Optional#absent()} if reference is undefined.
+ * @return Instance of {@link RangeConstraint}
*/
- public static PatternConstraint newPatternConstraint(final String pattern, final Optional description,
+ public static RangeConstraint newRangeConstraint(final T min, final T max, final Optional description,
final Optional reference) {
- return new PatternConstraintImpl(pattern, description, reference);
+ return new RangeConstraintImpl(min, max, description, reference);
}
-
/**
- * Creates a {@link LengthConstraint}.
+ * Creates a {@link RangeConstraint}.
*
- * Creates an instance of Length constraint based on supplied parameters
+ * Creates an instance of Range constraint based on supplied parameters
* with additional behaviour:
*
*
- * - {@link LengthConstraint#getErrorAppTag()} returns
length-out-of-specified-bounds
- * - {@link LengthConstraint#getErrorMessage() returns
The argument is out of bounds <min, max >
+ * - {@link RangeConstraint#getErrorAppTag()} returns
range-out-of-specified-bounds
+ * - {@link RangeConstraint#getErrorMessage()} returns
The argument is out of bounds <min, max >
*
*
- * @see LengthConstraint
*
- * @param min length-restricting lower bound value. The value MUST NOT be negative.
- * @param max length-restricting upper bound value. The value MUST NOT be negative.
- * @param description Description associated with constraint.
- * @param reference Reference associated with constraint.
- * @return Instance of {@link LengthConstraint}
- * @deprecated Use {@link #newLengthConstraint(Number, Number, Optional, Optional)} instead.
+ * @see RangeConstraint
+ *
+ * @param Type of constraint
+ * @param min value-restricting lower bound value. The value MUST NOT Be null.
+ * @param max value-restricting upper bound value. The value MUST NOT Be null.
+ * @param description Description associated with constraint. {@link Optional#absent()} if description is undefined.
+ * @param reference Reference associated with constraint. {@link Optional#absent()} if reference is undefined.
+ * @param errorAppTag error-app-tag associated with constraint.
+ * @param errorMessage error message associated with constraint.
+ * @return Instance of {@link RangeConstraint}
*/
- @Deprecated
- public static LengthConstraint lengthConstraint(final Number min, final Number max, final String description,
- final String reference) {
- return newLengthConstraint(min, max, Optional.fromNullable(description), Optional.fromNullable(reference));
+ public static RangeConstraint newRangeConstraint(final T min, final T max,
+ final Optional description, final Optional reference, final String errorAppTag,
+ final String errorMessage) {
+ return new RangeConstraintImpl(min, max, description, reference, errorAppTag, errorMessage);
}
/**
- * Creates a {@link RangeConstraint}.
+ * Creates a {@link PatternConstraint}.
*
- * Creates an instance of Range constraint based on supplied parameters
+ * Creates an instance of Pattern constraint based on supplied parameters
* with additional behaviour:
*
*
- * - {@link RangeConstraint#getErrorAppTag()} returns
range-out-of-specified-bounds
- * - {@link RangeConstraint#getErrorMessage() returns
The argument is out of bounds <min, max >
+ * - {@link PatternConstraint#getErrorAppTag()} returns
invalid-regular-expression
*
*
+ * @see PatternConstraint
*
- * @see RangeConstraint
- *
- * @param min value-restricting lower bound value. The value MUST NOT Be null.
- * @param max value-restricting upper bound value. The value MUST NOT Be null.
+ * @param pattern Regular expression, MUST NOT BE null.
* @param description Description associated with constraint.
* @param reference Reference associated with constraint.
- * @return Instance of {@link RangeConstraint}
- * @deprecated Use {@link #newRangeConstraint(Number, Number, Optional, Optional)} instead.
+ * @return Instance of {@link PatternConstraint}
*/
- @Deprecated
- public static RangeConstraint rangeConstraint(final Number min, final Number max, final String description,
- final String reference) {
- return newRangeConstraint(min, max, Optional.fromNullable(description), Optional.fromNullable(reference));
+ public static PatternConstraint newPatternConstraint(final String pattern, final Optional description,
+ final Optional reference) {
+ return new PatternConstraintImpl(pattern, description, reference);
}
/**
* Creates a {@link PatternConstraint}.
*
- * Creates an instance of Range constraint based on supplied parameters
+ * Creates an instance of Pattern constraint based on supplied parameters
* with additional behaviour:
*
*
* - {@link PatternConstraint#getErrorAppTag()} returns
invalid-regular-expression
*
*
- *
* @see PatternConstraint
*
- * @param pattern Regular expression, MUST NOT
+ * @param pattern Regular expression, MUST NOT BE null.
* @param description Description associated with constraint.
* @param reference Reference associated with constraint.
+ * @param errorAppTag error-app-tag associated with constraint.
+ * @param errorMessage error message associated with constraint.
* @return Instance of {@link PatternConstraint}
- * @deprecated Use {@link #newPatternConstraint(String, Optional, Optional)} Instead.
*/
- @Deprecated
- public static PatternConstraint patternConstraint(final String pattern, final String description,
- final String reference) {
- return newPatternConstraint(pattern, Optional.fromNullable(description), Optional.fromNullable(reference));
+ public static PatternConstraint newPatternConstraint(final String pattern, final Optional description,
+ final Optional reference, final String errorAppTag, final String errorMessage) {
+ return new PatternConstraintImpl(pattern, description, reference, errorAppTag, errorMessage);
}
}