Skip to content

Commit 0bb239a

Browse files
xhaggisothawo
authored andcommitted
Add missing hashCode and equals methods to JoinField.
Original Pull Request #1847 Closes #1846 (cherry picked from commit a16a87f)
1 parent 3336cea commit 0bb239a

File tree

1 file changed

+22
-0
lines changed
  • src/main/java/org/springframework/data/elasticsearch/core/join

1 file changed

+22
-0
lines changed

src/main/java/org/springframework/data/elasticsearch/core/join/JoinField.java

+22
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
*/
1616
package org.springframework.data.elasticsearch.core.join;
1717

18+
import java.util.Objects;
19+
20+
import org.springframework.data.annotation.PersistenceConstructor;
1821
import org.springframework.lang.Nullable;
1922

2023
/**
2124
* @author Subhobrata Dey
25+
* @author Sascha Woo
2226
* @since 4.1
2327
*/
2428
public class JoinField<ID> {
@@ -35,6 +39,7 @@ public JoinField(String name) {
3539
this(name, null);
3640
}
3741

42+
@PersistenceConstructor
3843
public JoinField(String name, @Nullable ID parent) {
3944
this.name = name;
4045
this.parent = parent;
@@ -52,4 +57,21 @@ public ID getParent() {
5257
public String getName() {
5358
return name;
5459
}
60+
61+
@Override
62+
public int hashCode() {
63+
return Objects.hash(name, parent);
64+
}
65+
66+
@Override
67+
public boolean equals(Object obj) {
68+
if (this == obj) {
69+
return true;
70+
}
71+
if (!(obj instanceof JoinField)) {
72+
return false;
73+
}
74+
JoinField other = (JoinField) obj;
75+
return Objects.equals(name, other.name) && Objects.equals(parent, other.parent);
76+
}
5577
}

0 commit comments

Comments
 (0)