T
- The subclass of Entity that this world model holds.public class DefaultWorldModel<T extends Entity> extends AbstractWorldModel<T>
Constructor and Description |
---|
DefaultWorldModel(java.lang.Class<? extends T> clazz)
Construct an empty world model.
|
Modifier and Type | Method and Description |
---|---|
void |
addEntityImpl(T e)
Subclasses should provide their implementation of addEntity here.
|
static DefaultWorldModel<Entity> |
create()
Construct an empty world model.
|
java.util.Collection<T> |
getAllEntities()
Get all entities in the world.
|
T |
getEntity(EntityID id)
Look up an entity by ID.
|
java.util.Iterator<T> |
iterator() |
void |
removeAllEntities()
Remove all entities from the world.
|
void |
removeEntity(EntityID id)
Remove an entity from the world.
|
addEntities, addEntity, addWorldModelListener, fireEntityAdded, fireEntityRemoved, isAllowed, merge, merge, registerAllowedClass, removeEntity, removeWorldModelListener
public DefaultWorldModel(java.lang.Class<? extends T> clazz)
clazz
- The class of objects that are allowed in this world model. This approach is a workaround for the limitations of Java generics.public static DefaultWorldModel<Entity> create()
public final java.util.Collection<T> getAllEntities()
WorldModel
public final void addEntityImpl(T e)
AbstractWorldModel
addEntityImpl
in class AbstractWorldModel<T extends Entity>
e
- The entity to add.public final void removeEntity(EntityID id)
WorldModel
id
- The entityID to remove.public final void removeAllEntities()
WorldModel
public final T getEntity(EntityID id)
WorldModel
id
- The EntityID to look up.public final java.util.Iterator<T> iterator()