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 / LengthConstraintEffectiveImpl.java
index 32ca55e4465b9722f164e380258eef9616044d28..98e11ecf65f328e030513e0b694ab7e4cea226fc 100644 (file)
@@ -25,16 +25,20 @@ public class LengthConstraintEffectiveImpl implements LengthConstraint {
 
     public LengthConstraintEffectiveImpl(final Number min, final Number max, final Optional<String> description,
             final Optional<String> reference) {
+        this(min, max, description.orNull(), reference.orNull(), "length-out-of-specified-bounds", "The argument is out of bounds <"
+                + min + ", " + max + ">");
+    }
 
+    public LengthConstraintEffectiveImpl(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 = "length-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 : "length-out-of-specified-bounds";
+        this.errorMessage = errorMessage != null ? errorMessage : "The argument is out of bounds <" + min + ", " + max
+                + ">";
     }
 
     @Override