Use String concatenation instead of StringBuffer/Builder
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / PatternConstraintImpl.java
index 8ab67a7636c02d72813cbc7dacea29b4de6fe2bc..edd9d5838c671346cb0a1553469d0c8b99735141 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
-
 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.PatternConstraint;
 
 /**
  * {@link Immutable} implementation of {@link PatternConstraint}
@@ -76,10 +76,10 @@ final class PatternConstraintImpl implements PatternConstraint, Immutable {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((description == null) ? 0 : description.hashCode());
-        result = prime * result + ((errorAppTag == null) ? 0 : errorAppTag.hashCode());
-        result = prime * result + ((errorMessage == null) ? 0 : errorMessage.hashCode());
-        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
+        result = prime * result + Objects.hashCode(description);
+        result = prime * result + Objects.hashCode(errorAppTag);
+        result = prime * result + Objects.hashCode(errorMessage);
+        result = prime * result + Objects.hashCode(reference);
         result = prime * result + regex.hashCode();
         return result;
     }
@@ -89,65 +89,27 @@ final class PatternConstraintImpl implements PatternConstraint, Immutable {
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof PatternConstraintImpl)) {
             return false;
         }
         final PatternConstraintImpl other = (PatternConstraintImpl) obj;
-        if (description == null) {
-            if (other.description != null) {
-                return false;
-            }
-        } else if (!description.equals(other.description)) {
-            return false;
-        }
-        if (errorAppTag == null) {
-            if (other.errorAppTag != null) {
-                return false;
-            }
-        } else if (!errorAppTag.equals(other.errorAppTag)) {
-            return false;
-        }
-        if (errorMessage == null) {
-            if (other.errorMessage != null) {
-                return false;
-            }
-        } else if (!errorMessage.equals(other.errorMessage)) {
-            return false;
-        }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
-        if (regex == null) {
-            if (other.regex != null) {
-                return false;
-            }
-        } else if (!regex.equals(other.regex)) {
-            return false;
-        }
-        return true;
+        return Objects.equals(description, other.description) && Objects.equals(errorAppTag, other.errorAppTag)
+                && Objects.equals(errorMessage, other.errorMessage) && Objects.equals(reference, other.reference)
+                && Objects.equals(regex, other.regex);
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("PatternConstraintImpl [regex=");
-        builder.append(regex);
-        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 "PatternConstraintImpl [regex=" +
+                regex +
+                ", description=" +
+                description +
+                ", reference=" +
+                reference +
+                ", errorAppTag=" +
+                errorAppTag +
+                ", errorMessage=" +
+                errorMessage +
+                "]";
     }
 }
\ No newline at end of file