public class ObjectFactory<T> extends Object
| Constructor and Description |
|---|
ObjectFactory(Class<T> clazz)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
T |
createObject(String spec)
Constructs and returns an object from one of the classes registered
with this factory.
|
Class<T> |
getFactoryClass()
Returns the class of which any object created by this factory
is guaranteed to be an instance.
|
String |
getNickName(Class<? extends T> clazz)
Returns the nickname corresponding to the no-arg constructor of
the given class.
|
String[] |
getNickNames()
Returns a list of the nicknames which have been registered.
|
boolean |
isRegistered(String name)
Indicates whether this factory knows about a given name.
|
void |
register(String nickName,
String className)
Registers a class with its nickname.
|
public Class<T> getFactoryClass()
public void register(String nickName, String className)
nickName - nicknameclassName - fully-qualified class namepublic String[] getNickNames()
public boolean isRegistered(String name)
name - namename can sensibly be passed to
createObject(java.lang.String)public T createObject(String spec) throws LoadException
spec - classname/nickname of class to instantiate,
followed by optional config textLoadException - if the load fails for unsurprising reasonsBeanConfigCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.