Use String concatenation instead of StringBuffer/Builder
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / RangeConstraintImpl.java
index 70acbc84eb4b37b55c7fcf348b358d5920fad8bd..885400b2db68a7ac7c16dac31868f96351a64067 100644 (file)
@@ -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