Implement the equals and hashCode contracts for Field.

Original Pull Request #2859
Closes #2858
This commit is contained in:
Aouichaoui Youssef 2024-02-26 20:57:17 +01:00 committed by GitHub
parent 7a8a9a15f1
commit 205d74b6db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,6 +19,8 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import java.util.Objects;
/**
* The most trivial implementation of a Field. The {@link #name} is updatable, so it may be changed during query
* preparation by the {@link org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter}.
@ -79,4 +81,16 @@ public class SimpleField implements Field {
public String toString() {
return getName();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SimpleField that)) return false;
return Objects.equals(name, that.name) && Objects.equals(fieldType, that.fieldType) && Objects.equals(path, that.path);
}
@Override
public int hashCode() {
return Objects.hash(name, fieldType, path);
}
}