|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.aduna.lang.reflect.KeyedObjectFactory<KEY,TYPE>
public class KeyedObjectFactory<KEY,TYPE>
A factory for objects of a specific abstract type (or interface) where the actual (runtime) type of the object is specified by a key. The factory requires all registered types to have a public constructor whose parameters can be specified upon creation of the factory.
| Constructor Summary | |
|---|---|
KeyedObjectFactory(Class<?>... paramTypes)
|
|
| Method Summary | |
|---|---|
void |
addType(KEY key,
Class<? extends TYPE> type)
Associates a type with a specific key. |
TYPE |
createInstance(KEY key,
Object... initArgs)
Creates a new instance of the type associated with the specified key. |
Class<? extends TYPE> |
getType(KEY key)
Gets the type that is associated with the specified key. |
void |
removeType(KEY key)
Removes the association between the specified key and the type that is currently associated with that key. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public KeyedObjectFactory(Class<?>... paramTypes)
| Method Detail |
|---|
public void addType(KEY key,
Class<? extends TYPE> type)
throws SecurityException
key - The key to be associated with the type.type - The type class.
IllegalArgumentException - If the specified type is an interface or abstract class, if it
isn't public, or if it doesn't have the required public
constructor.
SecurityException - If the factory is not allowed to access the type's constructor.public void removeType(KEY key)
key - A key specifying which key-type association to remove.public Class<? extends TYPE> getType(KEY key)
key - The key to get the type for.
public TYPE createInstance(KEY key,
Object... initArgs)
throws NoSuchTypeException,
TypeInstantiationException
key - A key indicating the type of the instance that should be created.
NoSuchTypeException - If the specified key is not associated with any type.
TypeInstantiationException - If, for some reason, the factory failed to create an instance of
the requested type.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||