public class EntityIDTable extends AbstractMap<Integer,EntityInstance> implements RemoveListener
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Method and Description |
---|---|
Set<Map.Entry<Integer,EntityInstance>> |
entrySet() |
static EntityIDTable |
forModel(Model mod)
Retreive or create an EntityID table for a model.
|
static EntityIDTable |
forModel(Model mod,
boolean populate)
Retreive or create an EntityID table for a model.
|
Integer |
getId(EntityInstance inst)
Gets the id for a EntityInstance.
|
Integer |
getId(EntityInstance inst,
boolean create)
Gets the id for a EntityInstance, optionally assigning a new ID if one
does not already exist
|
EntityInstance |
getInstance(Integer id)
Gets the EntityInstance for a specified ID
|
EntityInstance |
getInstance(String strid)
Gets the EntityInstance for a specified ID is a string form.
|
void |
populate(Model mod)
Assign identifiers to all the user objects in a model
|
void |
populate(PopulationBase pop)
Assign identifiers to all the objects in a population
|
void |
populate(Set<EntityInstance> objs)
Assign identifiers to a set of objects
|
void |
removeInstance(EntityInstance inst)
Remove an instance from the table
|
void |
removeNotify(EntityInstance inst)
Called when an EntityInstance is removed.
|
void |
removeTable()
Remove this table from the Model, and remove all the instances from it.
|
void |
setId(Integer id,
EntityInstance inst)
Set the identifier for a specified entity instance
|
public Integer getId(EntityInstance inst, boolean create) throws NotInModelException
inst
- The instance to get the ID from.create
- If true
, create and assign an ID if one
does not already existnull
if create is false,
and the object does not have an ID assigned.NotInModelException
- The instance is not contained in the Model
assiciated with this EntityIDTable.public Integer getId(EntityInstance inst)
inst
- The instance to get the ID from.null
if create is false,
and the object does not have an ID assigned.public EntityInstance getInstance(Integer id)
id
- The identifier to searchnull
if it could
not be foundpublic EntityInstance getInstance(String strid)
strid
- The identifier to search as a string. This consists of an
optional # followed by a sequence of digits.null
if it could
not be foundpublic void setId(Integer id, EntityInstance inst) throws DuplicateEIDException, DuplicateInstanceException
id
- The requested id.inst
- The instance to be identified.DuplicateEIDException
- The ID already exists in this table.DuplicateInstanceException
- The entity instance already has
an identifier in this tablepublic void removeInstance(EntityInstance inst)
inst
- The instance to removepublic void removeNotify(EntityInstance inst)
RemoveListener
population.removeInstance
method is called,
and this object is registered as a property of the Model by the
Model.addProperty
method.removeNotify
in interface RemoveListener
public void populate(Set<EntityInstance> objs)
objs
- The instances to be added to the tablepublic void populate(PopulationBase pop)
pop
- The populationpublic void populate(Model mod)
mod
- The model whose instances are added to the EntityIDTable.public static EntityIDTable forModel(Model mod, boolean populate)
mod
- The mode to get the table for.populate
- If true
, populate this table.public static EntityIDTable forModel(Model mod)
mod
- The mode to get the table for.public void removeTable()
public Set<Map.Entry<Integer,EntityInstance>> entrySet()
entrySet
in interface Map<Integer,EntityInstance>
entrySet
in class AbstractMap<Integer,EntityInstance>