Package net.spy.memcached
Class HashAlgorithmRegistry
java.lang.Object
net.spy.memcached.HashAlgorithmRegistry
Registry of known hashing algorithms for locating a server for a key. Useful
when configuring from files using algorithm names.
Please, make sure you register your algorithm with {
registerHashAlgorithm(String, HashAlgorithm)
before referring to it
by name
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map
<String, HashAlgorithm> Internal registry storage. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic HashAlgorithm
lookupHashAlgorithm
(String name) Tries to find selected hash algorithm using name provided.static void
registerHashAlgorithm
(String name, HashAlgorithm alg) Registers providedHashAlgorithm
instance with the given name.private static void
Validates algorithm instance.private static void
validateName
(String name) Validates name of the algorithm.
-
Field Details
-
REGISTRY
Internal registry storage.
-
-
Constructor Details
-
HashAlgorithmRegistry
private HashAlgorithmRegistry()
-
-
Method Details
-
registerHashAlgorithm
Registers providedHashAlgorithm
instance with the given name. Name is not case sensitive. Any registered algorithm with the same name will be substituted- Parameters:
name
- name of the algorithmalg
- algorithm instance to register
-
lookupHashAlgorithm
Tries to find selected hash algorithm using name provided.Note, that lookup is being performed using name's lower-case value
- Parameters:
name
- the algorithm name to be used for lookup- Returns:
- a
HashAlgorithm
instance ornull
if there's no algorithm with the specified name
-
validateName
Validates name of the algorithm. A non-empty name should be provided AnIllegalArgumentException
is being thrown in case of incorrect name- Parameters:
name
- a name to validate
-
validateAlgorithm
Validates algorithm instance. A non-null
instance should be provided. AnIllegalArgumentException
is being thrown in case ofnull
instance- Parameters:
alg
- aHashAlgorithm
instance to validate
-