Add equals and hashcode checks that include value

This commit is contained in:
Camotoy 2021-11-18 11:16:53 -05:00
parent 62492c961a
commit b8e980163c
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -219,4 +219,21 @@ public abstract class EntityMetadata<T> {
public String toString() {
return "EntityMetadata(id=" + id + ", type=" + type + ", value=" + getValue().toString() + ")";
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof EntityMetadata)) {
return false;
}
EntityMetadata<?> that = (EntityMetadata<?>) o;
return this.id == that.id && this.type == that.type && Objects.equals(this.getValue(), that.getValue());
}
@Override
public int hashCode() {
return Objects.hash(id, type, getValue());
}
}