This simplifies our equals() methods quite a bit.
Change-Id: If4d0fbf6bd45c58781a93f57d005b409ed9fe629
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
@Override
public boolean equals(final Object obj) {
- return this == obj || obj instanceof BiMapYangNamespaceContext
- && mapping.equals(((BiMapYangNamespaceContext) obj).mapping);
+ return this == obj || obj instanceof BiMapYangNamespaceContext other && mapping.equals(other.mapping);
}
@Override
}
@Override
- @SuppressFBWarnings("NP_NONNULL_RETURN_VIOLATION")
@Nullable String appTag() {
return null;
}
@Override
public final boolean equals(final @Nullable Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof CanonicalValueViolation)) {
- return false;
- }
- final CanonicalValueViolation other = (CanonicalValueViolation) obj;
- return Objects.equals(appTag(), other.appTag()) && Objects.equals(message(), other.message());
+ return this == obj || obj instanceof CanonicalValueViolation other
+ && Objects.equals(appTag(), other.appTag()) && Objects.equals(message(), other.message());
}
@Override
@Override
public final boolean equals(final @Nullable Object obj) {
- return this == obj || obj instanceof Decimal64 && equalsImpl((Decimal64) obj);
+ return this == obj || obj instanceof Decimal64 other && equalsImpl(other);
}
/**
@Override
public boolean equals(final @Nullable Object obj) {
- return obj == this || obj instanceof ErrorTag && elementBody.equals(((ErrorTag) obj).elementBody);
+ return obj == this || obj instanceof ErrorTag other && elementBody.equals(other.elementBody);
}
@Override
* @throws IOException if I/O error occurs
*/
public static @NonNull QName readFrom(final DataInput in) throws IOException {
- if (in instanceof QNameAwareDataInput) {
- return ((QNameAwareDataInput) in).readQName();
+ if (in instanceof QNameAwareDataInput aware) {
+ return aware.readQName();
}
final QNameModule module = QNameModule.readFrom(in);
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof QName)) {
- return false;
- }
- final QName other = (QName) obj;
- return Objects.equals(getLocalName(), other.getLocalName()) && module.equals(other.module);
+ return this == obj || obj instanceof QName other && getLocalName().equals(other.getLocalName())
+ && module.equals(other.module);
}
@Override
@Override
public void writeTo(final DataOutput out) throws IOException {
- if (out instanceof QNameAwareDataOutput) {
- ((QNameAwareDataOutput) out).writeQName(this);
+ if (out instanceof QNameAwareDataOutput aware) {
+ aware.writeQName(this);
} else {
module.writeTo(out);
out.writeUTF(getLocalName());
@Override
public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof QNameModule)) {
- return false;
- }
- final QNameModule other = (QNameModule) obj;
- return Objects.equals(revision, other.revision) && namespace.equals(other.namespace);
+ return this == obj || obj instanceof QNameModule other
+ && Objects.equals(revision, other.revision) && namespace.equals(other.namespace);
}
@Override
@Override
public boolean equals(final Object obj) {
- return this == obj || obj instanceof Revision && str.equals(((Revision)obj).str);
+ return this == obj || obj instanceof Revision other && str.equals(other.str);
}
@Override
@Override
public final boolean equals(final @Nullable Object obj) {
- return this == obj || obj instanceof Uint16 && value == ((Uint16)obj).value;
+ return this == obj || obj instanceof Uint16 other && value == other.value;
}
/**
@Override
public final boolean equals(final @Nullable Object obj) {
- return this == obj || obj instanceof Uint32 && value == ((Uint32)obj).value;
+ return this == obj || obj instanceof Uint32 other && value == other.value;
}
/**
@Override
public final boolean equals(final @Nullable Object obj) {
- return this == obj || obj instanceof Uint64 && value == ((Uint64)obj).value;
+ return this == obj || obj instanceof Uint64 other && value == other.value;
}
/**
@Override
public final boolean equals(final @Nullable Object obj) {
- return this == obj || obj instanceof Uint8 && value == ((Uint8)obj).value;
+ return this == obj || obj instanceof Uint8 other && value == other.value;
}
/**
@Override
public boolean equals(final @Nullable Object obj) {
- return this == obj || obj instanceof Qualified && getLocalName().equals(((Qualified) obj).getLocalName());
+ return this == obj || obj instanceof Qualified other && getLocalName().equals(other.getLocalName());
}
@Override
@Override
public boolean equals(final @Nullable Object obj) {
- return this == obj || obj instanceof Unqualified
- && getLocalName().equals(((AbstractQName) obj).getLocalName());
+ return this == obj || obj instanceof Unqualified other && getLocalName().equals(other.getLocalName());
}
@Override
@Override
public boolean equals(final Object obj) {
- return this == obj || obj instanceof XMLNamespace && namespace.equals(((XMLNamespace) obj).namespace);
+ return this == obj || obj instanceof XMLNamespace other && namespace.equals(other.namespace);
}
@Override