Package com.gengoai
Class Registry<T extends EnumValue>
- java.lang.Object
-
- com.gengoai.Registry<T>
-
- Type Parameters:
T
- the type parameter
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
HierarchicalRegistry
public class Registry<T extends EnumValue> extends Object implements Serializable
Registry for storing instances EnumValues
- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
canonicalName
The Canonical name.protected SerializableFunction<String,T>
newInstance
protected Map<String,T>
registry
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
checkName(CharSequence name)
Checks the name to make sure it is valid.boolean
contains(String name)
T
make(String name)
Creates an enum value for the given nameprotected String
normalize(String name)
Normalizes the nameT
valueOf(String name)
Returns the enum value for a given name throwing an exception if it does not exist.Collection<T>
values()
Gets all know enum values as a collection
-
-
-
Constructor Detail
-
Registry
public Registry(SerializableFunction<String,T> newInstance, Class<T> owner)
Instantiates a new Registry.- Parameters:
newInstance
- the new instanceowner
- the owner
-
-
Method Detail
-
checkName
protected String checkName(CharSequence name)
Checks the name to make sure it is valid.- Parameters:
name
- the name
-
contains
public boolean contains(String name)
-
make
public T make(String name)
Creates an enum value for the given name- Parameters:
name
- the name- Returns:
- the enum value
-
normalize
protected String normalize(String name)
Normalizes the name- Parameters:
name
- the name- Returns:
- the normalized name
-
valueOf
public T valueOf(String name)
Returns the enum value for a given name throwing an exception if it does not exist.- Parameters:
name
- the name- Returns:
- the enum value
-
values
public Collection<T> values()
Gets all know enum values as a collection- Returns:
- the collection
-
-