T
- type of hashed objectpublic class HashCoder<T> extends java.lang.Object implements HashCodeCalculator<T>, UniformMatcher<T>
HashCoderMap
.
This class provides substitute hash values and equals
implementation. To be null
-safe all three
arguments of HashCoder(HashCodeCalculator, Matcher, Function1)
need to be null
-safe. The default implementations used
in the constructors with less arguments are null
-safe.
DEFAULT
IDENTICAL
Constructor and Description |
---|
HashCoder(Function1<T,T> copier)
Constructor.
|
HashCoder(HashCodeCalculator<? super T> codeCalculator)
Constructor.
|
HashCoder(HashCodeCalculator<? super T> codeCalculator,
Matcher<? super T,? super T> matcher)
Constructor.
|
HashCoder(HashCodeCalculator<? super T> codeCalculator,
Matcher<? super T,? super T> matcher,
Function1<T,T> copier)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areEqual(T object1,
T object2)
Are the given two objects considered equal?
|
T |
copy(T key)
Copy a key.
|
int |
getHashCode(T obj)
Get the hash code value of the given object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
identical
public HashCoder(@NotNull HashCodeCalculator<? super T> codeCalculator, @NotNull Matcher<? super T,? super T> matcher, @NotNull Function1<T,T> copier)
codeCalculator
- calculator for hash codesmatcher
- equality checkercopier
- copier for incoming and outgoing keys,
useful to make keys immutable which
is a basic requirements for hash keyspublic HashCoder(@NotNull HashCodeCalculator<? super T> codeCalculator, @NotNull Matcher<? super T,? super T> matcher)
This used simple copying for the keys.
codeCalculator
- calculator for hash codesmatcher
- equality checkerpublic HashCoder(@NotNull HashCodeCalculator<? super T> codeCalculator)
Objects.equals(java.lang.Object, java.lang.Object)
and simple copying for the keys.codeCalculator
- hash code calculatorpublic HashCoder(@NotNull Function1<T,T> copier)
Hashcode and equality checks are just using the standard implementation from the key objects.
copier
- copier for incoming and outgoing keyspublic int getHashCode(T obj)
HashCodeCalculator
getHashCode
in interface HashCodeCalculator<T>
obj
- object for which the hash code is requestedpublic boolean areEqual(T object1, T object2)
Matcher