Java 17 allows us to make the method much simpler, use instanceof
pattern match.
Change-Id: I0d447a5d4db7ce265277896fd24901f875fac0ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
@Override
public boolean equals(final @Nullable Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof PatternExpression)) {
- return false;
- }
- final PatternExpression other = (PatternExpression) obj;
- return regex.equals(other.regex) && pattern.equals(other.pattern);
+ return this == obj || obj instanceof PatternExpression other
+ && regex.equals(other.regex) && pattern.equals(other.pattern);
}
@Override