public class PrototypeFactory<K,T> extends Object
new instance
request. Based on the
arguments, a matching constructor, if any, is located and invoked.
Constructor and Description |
---|
PrototypeFactory() |
Modifier and Type | Method and Description |
---|---|
(package private) Constructor<? extends T> |
findConstructor(Class<? extends T> cls,
Class<?>[] types)
Finds a constructor of the given class with given argument types.
|
(package private) Class<?>[] |
getConstructorParameterTypes(Object... args) |
Set<K> |
getRegisteredKeys()
Gets the keys registered in this factory.
|
T |
newInstance(K key,
Object... args)
Create a new instance of the type registered before
with the given key, if any.
|
void |
register(K key,
Class<? extends T> prototype)
Register the given class with the given key.
|
public void register(K key, Class<? extends T> prototype)
key
- a non-null key.prototype
- a type.public T newInstance(K key, Object... args)
key
- a key to identify a registered type.args
- arguments to pass to the constructor of the type.public Set<K> getRegisteredKeys()
Constructor<? extends T> findConstructor(Class<? extends T> cls, Class<?>[] types)
Copyright © 2006–2015 Apache Software Foundation. All rights reserved.