T
- The enum containing all types.S
- The setup type used.public abstract class FactoryGame<T extends Enum<T>,S extends SetupGame> extends Object
SetupGame
considering an input enumeration. This way it is possible to create new
instances of object related to their type by sharing the same data.
Sample implementation:
public class Factory extends FactoryGame<EntityType, SetupGame> { public Factory() { super(EntityType.class); load(); } @Override protected SetupGame createSetup(EntityType type) { return new SetupGame(Media.get(type.name() + ".xml")); } }
Constructor and Description |
---|
FactoryGame(Class<T> enumType)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addSetup(T type,
S setup)
Add a setup reference for the specified type.
|
protected abstract S |
createSetup(T type)
Get setup instance from the type.
|
S |
getSetup(T type)
Get a setup reference from its type.
|
T[] |
getTypes()
Get the types list.
|
void |
load()
Load setup for each type.
|
protected abstract S createSetup(T type)
type
- The enum type.public void load()
public S getSetup(T type)
type
- The reference type.public T[] getTypes()
Copyright © 2014 Byron 3D Games Studio. All rights reserved.