Package com.scurrilous.circe.impl
Class AbstractHashProvider<P extends HashParameters>
java.lang.Object
com.scurrilous.circe.impl.AbstractHashProvider<P>
- Type Parameters:
P- base supported hash parameters type
- All Implemented Interfaces:
HashProvider
- Direct Known Subclasses:
Crc32cSse42Provider,StandardCrcProvider
public abstract class AbstractHashProvider<P extends HashParameters>
extends Object
implements HashProvider
Base implementation for hash function providers.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractHashProvider(Class<P> parametersClass) Constructs a newAbstractHashProviderwith the given base parameters class. -
Method Summary
Modifier and TypeMethodDescriptionprotected StatelessHashcreateCacheable(P params, EnumSet<HashSupport> required) Called bygetCacheable(P, java.util.EnumSet<com.scurrilous.circe.HashSupport>)to create new cacheable stateless hash functions.createStateful(HashParameters params) Creates a stateful hash function using the given parameters.protected abstract Hashget(P params, EnumSet<HashSupport> required) Requests a hash function using the given parameters and support flags.protected final HashgetCacheable(P params, EnumSet<HashSupport> required) Called by implementations that support caching of stateless hash functions when a cached instance is desired.getIncrementalInt(HashParameters params) Requests an incremental, stateless, int-width hash function with the given parameters.getIncrementalLong(HashParameters params) Requests an incremental, stateless, long-width hash function with the given parameters.getStatelessInt(HashParameters params) Requests a stateless, int-width hash function with the given parameters.getStatelessLong(HashParameters params) Requests a stateless, long-width hash function with the given parameters.final EnumSet<HashSupport>querySupport(HashParameters params) Returns information about the available implementations corresponding to the given hash algorithm parameters.protected abstract EnumSet<HashSupport>querySupportTyped(P params) Implemented by subclasses to provide information about the available implementations corresponding to the given hash algorithm parameters.
-
Constructor Details
-
AbstractHashProvider
Constructs a newAbstractHashProviderwith the given base parameters class.- Parameters:
parametersClass- the base hash parameters class supported
-
-
Method Details
-
querySupport
Description copied from interface:HashProviderReturns information about the available implementations corresponding to the given hash algorithm parameters.- Specified by:
querySupportin interfaceHashProvider- Parameters:
params- the hash algorithm parameters- Returns:
- a set of flags indicating the level of support
-
querySupportTyped
Implemented by subclasses to provide information about the available implementations corresponding to the given hash algorithm parameters. Called byquerySupport(com.scurrilous.circe.HashParameters)if the hash parameters match the base type supported by this provider.- Parameters:
params- the hash algorithm parameters- Returns:
- a set of flags indicating the level of support
-
get
Requests a hash function using the given parameters and support flags. This method is only responsible for checking support flags returned byquerySupportTyped(P).To support caching of stateless hash functions, call
getCacheable(P, java.util.EnumSet<com.scurrilous.circe.HashSupport>)from this method and implementcreateCacheable(P, java.util.EnumSet<com.scurrilous.circe.HashSupport>).- Parameters:
params- the hash algorithm parametersrequired- the required hash support flags- Returns:
- a hash function
- Throws:
UnsupportedOperationException- if this provider cannot support the given parameters
-
getCacheable
Called by implementations that support caching of stateless hash functions when a cached instance is desired. If a cached instance is not available, this method callscreateCacheable(P, java.util.EnumSet<com.scurrilous.circe.HashSupport>)to create one, which is then cached (if caching is available).- Parameters:
params- the hash algorithm parametersrequired- the required hash support flags- Returns:
- a hash function
- Throws:
UnsupportedOperationException- if this provider cannot support the given parameters
-
createCacheable
Called bygetCacheable(P, java.util.EnumSet<com.scurrilous.circe.HashSupport>)to create new cacheable stateless hash functions. The default implementation simply throwsUnsupportedOperationException.- Parameters:
params- the hash algorithm parametersrequired- the required hash support flags- Returns:
- a stateless hash function
- Throws:
UnsupportedOperationException- if this provider cannot support the given parameters
-
createStateful
Description copied from interface:HashProviderCreates a stateful hash function using the given parameters.- Specified by:
createStatefulin interfaceHashProvider- Parameters:
params- the hash algorithm parameters- Returns:
- a stateful hash function
-
getStatelessInt
Description copied from interface:HashProviderRequests a stateless, int-width hash function with the given parameters. Because not all stateless hash functions are incremental, this method may be able to return implementations not supported by or more optimized thanHashProvider.getIncrementalInt(com.scurrilous.circe.HashParameters).- Specified by:
getStatelessIntin interfaceHashProvider- Parameters:
params- the hash algorithm parameters- Returns:
- a stateless int-width hash function
-
getStatelessLong
Description copied from interface:HashProviderRequests a stateless, long-width hash function with the given parameters. Because not all stateless hash functions are incremental, this method may be able to return implementations not supported by or more optimized thanHashProvider.getIncrementalLong(com.scurrilous.circe.HashParameters).Note that this method may return a less efficient hash function than
HashProvider.getStatelessInt(com.scurrilous.circe.HashParameters)for hashes of 32 bits or less.- Specified by:
getStatelessLongin interfaceHashProvider- Parameters:
params- the hash algorithm parameters- Returns:
- a stateless long-width hash function
-
getIncrementalInt
Description copied from interface:HashProviderRequests an incremental, stateless, int-width hash function with the given parameters. Note that although an algorithm may be available in incremental form, some potentially more optimized implementations may not support that form, and therefore cannot be provided be this method.- Specified by:
getIncrementalIntin interfaceHashProvider- Parameters:
params- the hash algorithm parameters- Returns:
- a stateful int-width hash function
-
getIncrementalLong
Description copied from interface:HashProviderRequests an incremental, stateless, long-width hash function with the given parameters. Note that although an algorithm may be available in incremental form, some potentially more optimized implementations may not support that form, and therefore cannot be provided be this method.Also note that this method may return a less efficient hash function than
HashProvider.getIncrementalInt(com.scurrilous.circe.HashParameters)for hashes of 32 bits or less.- Specified by:
getIncrementalLongin interfaceHashProvider- Parameters:
params- the hash algorithm parameters- Returns:
- a stateful long-width hash function
-