*/
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}
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;
}
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