|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.kolls.railworld.ExtensibleFactory<T>
T - The type of object to create in the factory. Must implement SaveLoadpublic class ExtensibleFactory<T extends SaveLoad>
A factory that creates instances by name and is extensible. New types can be added (e.g. by plugins) and then instantiated by other classes. Works with the save/load system to allow saving and restoring of various classes. Type parameter is supertype of all the items for that factory.
SaveLoad| Constructor Summary | |
|---|---|
ExtensibleFactory()
Create a new extensible factory. |
|
| Method Summary | |
|---|---|
void |
addType(T item)
Adds a new subclass of the master item type to the factory. |
java.util.ArrayList<T> |
allTypes()
Returns an instance of each item class known. |
void |
clear()
Removes all items. |
T |
createInstance(java.lang.String type)
Given the Object.toString() value, creates a new instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExtensibleFactory()
| Method Detail |
|---|
public void clear()
public void addType(T item)
item - An instance of the class to addpublic java.util.ArrayList<T> allTypes()
T[]
public T createInstance(java.lang.String type)
throws java.lang.ClassNotFoundException
Object.toString() value, creates a new instance.
type - The name of the item class, as defined in the toString method.
java.lang.ClassNotFoundException - If no item class is found to match the requested type.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||