X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=yang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Futil%2FRangeConstraintImpl.java;h=885400b2db68a7ac7c16dac31868f96351a64067;hb=9c6cbdaf5bb5e1ea8066558927e9ea674c0b9d51;hp=70acbc84eb4b37b55c7fcf348b358d5920fad8bd;hpb=b3e9bdc78ca793648a8cc69b68af0c7f46727cd4;p=yangtools.git diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java index 70acbc84eb..885400b2db 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java @@ -7,13 +7,13 @@ */ package org.opendaylight.yangtools.yang.model.util; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import java.util.Objects; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; - /** * {@link Immutable} implementation of {@link LengthConstraint}. * @@ -82,12 +82,12 @@ final class RangeConstraintImpl implements RangeConstraint, Immutable { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + Objects.hashCode(description); result = prime * result + errorAppTag.hashCode(); result = prime * result + errorMessage.hashCode(); result = prime * result + max.hashCode(); result = prime * result + min.hashCode(); - result = prime * result + ((reference == null) ? 0 : reference.hashCode()); + result = prime * result + Objects.hashCode(reference); return result; } @@ -96,60 +96,28 @@ final class RangeConstraintImpl implements RangeConstraint, Immutable { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if (!(obj instanceof RangeConstraintImpl)) { return false; } final RangeConstraintImpl other = (RangeConstraintImpl) obj; - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { - return false; - } - if (max == null) { - if (other.max != null) { - return false; - } - } else if (!max.equals(other.max)) { - return false; - } - if (min == null) { - if (other.min != null) { - return false; - } - } else if (!min.equals(other.min)) { - return false; - } - if (reference == null) { - if (other.reference != null) { - return false; - } - } else if (!reference.equals(other.reference)) { - return false; - } - return true; + return Objects.equals(description, other.description) && Objects.equals(max, other.max) + && Objects.equals(min, other.min) && Objects.equals(reference, other.reference); } @Override public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("RangeConstraintImpl [min="); - builder.append(min); - builder.append(", max="); - builder.append(max); - builder.append(", description="); - builder.append(description); - builder.append(", reference="); - builder.append(reference); - builder.append(", errorAppTag="); - builder.append(errorAppTag); - builder.append(", errorMessage="); - builder.append(errorMessage); - builder.append("]"); - return builder.toString(); + return "RangeConstraintImpl [min=" + + min + + ", max=" + + max + + ", description=" + + description + + ", reference=" + + reference + + ", errorAppTag=" + + errorAppTag + + ", errorMessage=" + + errorMessage + + "]"; } } \ No newline at end of file