X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Frfc6020%2Feffective%2Ftype%2FPatternConstraintEffectiveImpl.java;h=d8799648f621afc21a084bf0a08df6e8950dda15;hb=635af1cfca70d0be0192f997c155d80cbbc5ba5d;hp=1b8bbc91267885c8de15710b7049ca497139a89b;hpb=aa0d59e9afecc484e8d0e219d3156e7817266e28;p=yangtools.git diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java index 1b8bbc9126..d8799648f6 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java @@ -17,21 +17,24 @@ public class PatternConstraintEffectiveImpl implements PatternConstraint { private final String regEx; private final String description; private final String reference; - private final String errorAppTag; private final String errorMessage; public PatternConstraintEffectiveImpl(final String regex, final Optional description, final Optional reference) { + this(regex, description.orNull(), reference.orNull(), "invalid-regular-expression", String.format( + "String %s is not valid regular expression.", regex)); + } + public PatternConstraintEffectiveImpl(final String regex, final String description, final String reference, + final String errorAppTag, final String errorMessage) { super(); - this.regEx = Preconditions.checkNotNull(regex, "regex must not be null."); - this.description = description.orNull(); - this.reference = reference.orNull(); - - errorAppTag = "invalid-regular-expression"; - errorMessage = String.format("String %s is not valid regular expression.", regex); + this.description = description; + this.reference = reference; + this.errorAppTag = errorAppTag != null ? errorAppTag : "invalid-regular-expression"; + this.errorMessage = errorMessage != null ? errorMessage : String.format( + "String %s is not valid regular expression.", regex); } @Override @@ -83,39 +86,19 @@ public class PatternConstraintEffectiveImpl implements PatternConstraint { return false; } final PatternConstraintEffectiveImpl other = (PatternConstraintEffectiveImpl) obj; - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { + if (!Objects.equals(description, other.description)) { return false; } - if (errorAppTag == null) { - if (other.errorAppTag != null) { - return false; - } - } else if (!errorAppTag.equals(other.errorAppTag)) { + if (!Objects.equals(errorAppTag, other.errorAppTag)) { return false; } - if (errorMessage == null) { - if (other.errorMessage != null) { - return false; - } - } else if (!errorMessage.equals(other.errorMessage)) { + if (!Objects.equals(errorMessage, other.errorMessage)) { return false; } - if (reference == null) { - if (other.reference != null) { - return false; - } - } else if (!reference.equals(other.reference)) { + if (!Objects.equals(reference, other.reference)) { return false; } - if (regEx == null) { - if (other.regEx != null) { - return false; - } - } else if (!regEx.equals(other.regEx)) { + if (!Objects.equals(regEx, other.regEx)) { return false; } return true;