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 theHasherobjects 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[]functionsprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description AbstractCompositeHashFunction(HashFunction... functions)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private HasherfromHashers(Hasher[] hashers)(package private) abstract HashCodemakeHash(Hasher[] hashers)Constructs aHashCodefrom theHasherobjects of the functions.HashernewHasher()Begins a new hash code computation by returning an initialized, statefulHasherinstance that is ready to receive data.HashernewHasher(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 aHashCodefrom theHasherobjects 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:HashFunctionBegins a new hash code computation by returning an initialized, statefulHasherinstance 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:HashFunctionBegins 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:
newHasherin interfaceHashFunction- Overrides:
newHasherin classAbstractHashFunction
-
-