public interface HashImmutable
equals(Object)
and hashCode() are immutable (will never change) and thus the results of equals(Object)
and hashCode() can never change during the life span of an instance of this type.
This additional contract is required to enable the proper use of Object.equals(Object) and
Object.hashCode(), because Object.hashCode()-depending hashing depends on this behavior
to remain consistent.
For any type not implementing this class (or not commonly known to be immutable, like String,
Integer, etc.), do not rely on neither Object.equals(Object) nor Object.hashCode(),
as implementations overriding them are potentially broken in terms of the required behavior (e.g. JDK
implementations of Collection are).
For those cases, use an externally defined Equalator or HashEqualator with fitting implementation
instead.
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other)
Marker declaration to indicate that for classes of this type,
Object.equals(Object) can be properly
used. |
int |
hashCode()
Marker declaration to indicate that for classes of this type,
Object.hashCode() can be properly
used. |
boolean equals(Object other)
Object.equals(Object) can be properly
used.equals in class Objectother - the reference object with which to compare.true if this object can be treated as the same as other
false otherwise.hashCode()int hashCode()
Object.hashCode() can be properly
used.hashCode in class Objectequals(Object)equals(java.lang.Object)Copyright © 2022 MicroStream Software. All rights reserved.