Bug 5200: Yang parser doesn't fill error-app-tag and error-message in constraints
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / type / RangeConstraintEffectiveImpl.java
index 0b1b71c809ef9cbf97b19d9a7abd2d72f06c4773..5df9d97e0a996b62d4681b1cf86f3b57d8d6bb3e 100644 (file)
@@ -26,16 +26,20 @@ public class RangeConstraintEffectiveImpl implements RangeConstraint {
 
     public RangeConstraintEffectiveImpl(final Number min, final Number max, final Optional<String> description,
             final Optional<String> reference) {
+        this(min, max, description.orNull(), reference.orNull(), "range-out-of-specified-bounds",
+                "The argument is out of bounds <" + min + ", " + max + ">");
+    }
 
+    public RangeConstraintEffectiveImpl(final Number min, final Number max, final String description,
+            final String reference, final String errorAppTag, final String errorMessage) {
         super();
-
         this.min = Preconditions.checkNotNull(min, "min must not be null.");
         this.max = Preconditions.checkNotNull(max, "max must not be null.");
-        this.description = description.orNull();
-        this.reference = reference.orNull();
-
-        this.errorAppTag = "range-out-of-specified-bounds";
-        this.errorMessage = "The argument is out of bounds <" + min + ", " + max + ">";
+        this.description = description;
+        this.reference = reference;
+        this.errorAppTag = errorAppTag != null ? errorAppTag : "range-out-of-specified-bounds";
+        this.errorMessage = errorMessage != null ? errorMessage : "The argument is out of bounds <" + min + ", " + max
+                + ">";
     }
 
     @Override
@@ -110,19 +114,8 @@ public class RangeConstraintEffectiveImpl implements RangeConstraint {
 
     @Override
     public String toString() {
-        return RangeConstraintEffectiveImpl.class.getSimpleName() +
-                " [min=" +
-                min +
-                ", max=" +
-                max +
-                ", description=" +
-                description +
-                ", reference=" +
-                reference +
-                ", errorAppTag=" +
-                errorAppTag +
-                ", errorMessage=" +
-                errorMessage +
-                "]";
+        return RangeConstraintEffectiveImpl.class.getSimpleName() + " [min=" + min + ", max=" + max + ", description="
+                + description + ", reference=" + reference + ", errorAppTag=" + errorAppTag + ", errorMessage="
+                + errorMessage + "]";
     }
 }