Package com.google.common.hash
Class AbstractCompositeHashFunction
java.lang.Object
com.google.common.hash.AbstractHashFunction
com.google.common.hash.AbstractCompositeHashFunction
- All Implemented Interfaces:
HashFunction
- Direct Known Subclasses:
Hashing.ConcatenatedHashFunction
An abstract composition of multiple hash functions. newHasher() delegates to the
Hasher
objects of the delegate hash functions, and in the end, they are used by
makeHash(Hasher[]) that constructs the final HashCode
.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final HashFunction[]
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Hasher
fromHashers
(Hasher[] hashers) (package private) abstract HashCode
Constructs aHashCode
from theHasher
objects of the functions.Begins a new hash code computation by returning an initialized, statefulHasher
instance that is ready to receive data.newHasher
(int expectedInputSize) Begins a new hash code computation asHashFunction.newHasher()
, but provides a hint of the expected size of the input (in bytes).Methods inherited from class com.google.common.hash.AbstractHashFunction
hashBytes, hashBytes, hashBytes, hashInt, hashLong, hashObject, hashString, hashUnencodedChars
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.common.hash.HashFunction
bits
-
Field Details
-
functions
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
AbstractCompositeHashFunction
AbstractCompositeHashFunction(HashFunction... functions)
-
-
Method Details
-
makeHash
Constructs aHashCode
from theHasher
objects of the functions. Each of them has consumed the entire input and they are ready to output aHashCode
. The order of the hashers are the same order as the functions given to the constructor. -
newHasher
Description copied from interface:HashFunction
Begins a new hash code computation by returning an initialized, statefulHasher
instance that is ready to receive data. Example:HashFunction hf = Hashing.md5(); HashCode hc = hf.newHasher() .putLong(id) .putBoolean(isActive) .hash();
-
newHasher
Description copied from interface:HashFunction
Begins a new hash code computation asHashFunction.newHasher()
, but provides a hint of the expected size of the input (in bytes). This is only important for non-streaming hash functions (hash functions that need to buffer their whole input before processing any of it).- Specified by:
newHasher
in interfaceHashFunction
- Overrides:
newHasher
in classAbstractHashFunction
-
fromHashers
-