Use instanceof pattern to simplify the equals method.
Change-Id: I31eb8b095a701a43ece60008bc1b797a9ef6ebac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
@Override
public final boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof AbstractPathArgument)) {
- return false;
- }
- final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
- return type.equals(other.type) && Objects.equals(getKey(), other.getKey())
- && getCaseType().equals(other.getCaseType());
+ return this == obj || obj instanceof AbstractPathArgument<?> other && type.equals(other.type)
+ && Objects.equals(getKey(), other.getKey()) && getCaseType().equals(other.getCaseType());
}
@Override