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 |
---|---|
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.Copyright © 2006–2017 Apache Software Foundation. All rights reserved.