Skip to content

Commit f2b01e5

Browse files
authored
Simplify SearchGroup#equals and SearchGroup.MergedGroup#equals (#15888)
* Simplify SearchGroup#equals Signed-off-by: Binlong Gao <gbinlong@amazon.com> * Simplify SearchGroup.MergedGroup#equals Signed-off-by: Binlong Gao <gbinlong@amazon.com> --------- Signed-off-by: Binlong Gao <gbinlong@amazon.com>
1 parent 05a788f commit f2b01e5

1 file changed

Lines changed: 3 additions & 21 deletions

File tree

lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.List;
2626
import java.util.Map;
2727
import java.util.NavigableSet;
28+
import java.util.Objects;
2829
import java.util.TreeSet;
2930
import org.apache.lucene.search.FieldComparator;
3031
import org.apache.lucene.search.Pruning;
@@ -62,17 +63,7 @@ public boolean equals(Object o) {
6263
if (this == o) return true;
6364
if (o == null || getClass() != o.getClass()) return false;
6465

65-
SearchGroup<?> that = (SearchGroup<?>) o;
66-
67-
if (groupValue == null) {
68-
if (that.groupValue != null) {
69-
return false;
70-
}
71-
} else if (!groupValue.equals(that.groupValue)) {
72-
return false;
73-
}
74-
75-
return true;
66+
return Objects.equals(groupValue, ((SearchGroup<?>) o).groupValue);
7667
}
7768

7869
@Override
@@ -141,16 +132,7 @@ public boolean equals(Object _other) {
141132
// same groupValue
142133
assert neverEquals(_other);
143134

144-
if (_other instanceof MergedGroup) {
145-
MergedGroup<?> other = (MergedGroup<?>) _other;
146-
if (groupValue == null) {
147-
return other.groupValue == null;
148-
} else {
149-
return groupValue.equals(other.groupValue);
150-
}
151-
} else {
152-
return false;
153-
}
135+
return _other instanceof MergedGroup<?> other && Objects.equals(groupValue, other.groupValue);
154136
}
155137

156138
@Override

0 commit comments

Comments
 (0)