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