Microservice: Introduction to Spring & Http
-> equals() Contract
1. reflexive: an object must equal itself
2. symmetric: x.equals(y) must return the same result as y.equals(x)
3. transitive: if x.equals(y) and y.equals(z), then also x.equals(z)
4. consistent: the value of equals() should change only if a property that is contained in equals() changes (no randomness allowed)
-> hashCode() Contract
All three criteria in the hashCode() contract mention the equals() method in some way:
1. internal consistency: the value of hashCode() may only change if a property that is in equals() changes
2. equals consistency: objects that are equal to each other must return the same hashCode
3. collisions: unequal objects may have the same hashCode
Комментарии
Отправить комментарий