Skip to content

Commit 205d74b

Browse files
authored
Implement the equals and hashCode contracts for Field.
Original Pull Request spring-projects#2859 Closes spring-projects#2858
1 parent 7a8a9a1 commit 205d74b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/org/springframework/data/elasticsearch/core/query/SimpleField.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.springframework.lang.Nullable;
2020
import org.springframework.util.Assert;
2121

22+
import java.util.Objects;
23+
2224
/**
2325
* The most trivial implementation of a Field. The {@link #name} is updatable, so it may be changed during query
2426
* preparation by the {@link org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter}.
@@ -79,4 +81,16 @@ public String getPath() {
7981
public String toString() {
8082
return getName();
8183
}
84+
85+
@Override
86+
public boolean equals(Object o) {
87+
if (this == o) return true;
88+
if (!(o instanceof SimpleField that)) return false;
89+
return Objects.equals(name, that.name) && Objects.equals(fieldType, that.fieldType) && Objects.equals(path, that.path);
90+
}
91+
92+
@Override
93+
public int hashCode() {
94+
return Objects.hash(name, fieldType, path);
95+
}
8296
}

0 commit comments

Comments
 (0)