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
abstract class AbstractCompositeHashFunction extends AbstractHashFunction
An abstract composition of multiple hash functions. newHasher() delegates to theHasher
objects of the delegate hash functions, and in the end, they are used by makeHash(Hasher[]) that constructs the finalHashCode
.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) HashFunction[]
functions
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description AbstractCompositeHashFunction(HashFunction... functions)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private Hasher
fromHashers(Hasher[] hashers)
(package private) abstract HashCode
makeHash(Hasher[] hashers)
Constructs aHashCode
from theHasher
objects of the functions.Hasher
newHasher()
Begins a new hash code computation by returning an initialized, statefulHasher
instance that is ready to receive data.Hasher
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 Detail
-
functions
final HashFunction[] functions
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractCompositeHashFunction
AbstractCompositeHashFunction(HashFunction... functions)
-
-
Method Detail
-
makeHash
abstract HashCode makeHash(Hasher[] hashers)
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
public Hasher 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
public Hasher newHasher(int expectedInputSize)
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
-
-