org.commonreality.object.manager.impl
Class GeneralObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>

java.lang.Object
  extended by org.commonreality.object.manager.impl.GeneralObjectManager<O,L>
All Implemented Interfaces:
IMutableObjectManager<O,L>, IObjectManager<O,L>
Direct Known Subclasses:
AgentObjectManager, EfferentCommandManager, RealObjectManager, SensorObjectManager, SensoryObjectManager

public class GeneralObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
extends java.lang.Object
implements IMutableObjectManager<O,L>

Handles the adding, updating, and removal of a specific type of simulation object - it also deals with the listeners. This class is generally hidden from users as they are generally encapsulated within the ObjectManager

Author:
developer

Constructor Summary
GeneralObjectManager()
           
 
Method Summary
 boolean add(java.util.Collection<O> objects)
          add all of the objects to the manager and fire an appropriate event
 boolean add(O object)
          add this single object and fire an event
 void addListener(L listener, java.util.concurrent.Executor executor)
          add a listener that will have its objectAdded,removed,updated methods fired appropriately on the provided executor
 boolean contains(IIdentifier identifier)
          does this object manager have an object O that is keyed on this identifier
 O get(IIdentifier identifier)
          return the object O that is keyed on identifier
 java.util.Collection<IIdentifier> getIdentifiers()
          return all the identifiers that have matched objects
 java.util.Collection<L> getListeners()
          return a collection containing all the installed listeners
 boolean hasListeners()
          are there any registered listeners?
 boolean remove(java.util.Collection<IIdentifier> identifiers)
          remove all the objects that are keyed on identifier.
 boolean remove(IIdentifier id)
          remove the object that is keyed on id and fire an event
 void removeListener(L listener)
          remove said listener
 boolean update(java.util.Collection<IObjectDelta> deltas)
          update all these obejcts
 boolean update(IObjectDelta delta)
          update the object that is described by this delta with this delta.
 void waitForChange()
          wait until something has been added, removed, updated
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralObjectManager

public GeneralObjectManager()
Method Detail

addListener

public void addListener(L listener,
                        java.util.concurrent.Executor executor)
add a listener that will have its objectAdded,removed,updated methods fired appropriately on the provided executor

Specified by:
addListener in interface IObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
listener -
executor -

removeListener

public void removeListener(L listener)
remove said listener

Specified by:
removeListener in interface IObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
listener -

hasListeners

public boolean hasListeners()
are there any registered listeners?

Specified by:
hasListeners in interface IObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Returns:

getListeners

public java.util.Collection<L> getListeners()
return a collection containing all the installed listeners

Specified by:
getListeners in interface IObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Returns:

update

public boolean update(IObjectDelta delta)
update the object that is described by this delta with this delta. and fire an event

Specified by:
update in interface IMutableObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
delta -

update

public boolean update(java.util.Collection<IObjectDelta> deltas)
update all these obejcts

Specified by:
update in interface IMutableObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
deltas -

add

public boolean add(O object)
add this single object and fire an event

Specified by:
add in interface IMutableObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
object -

add

public boolean add(java.util.Collection<O> objects)
add all of the objects to the manager and fire an appropriate event

Specified by:
add in interface IMutableObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
objects -

remove

public boolean remove(IIdentifier id)
remove the object that is keyed on id and fire an event

Specified by:
remove in interface IMutableObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
id -

remove

public boolean remove(java.util.Collection<IIdentifier> identifiers)
remove all the objects that are keyed on identifier. this fire a bulk remove event

Specified by:
remove in interface IMutableObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
identifiers -

get

public O get(IIdentifier identifier)
return the object O that is keyed on identifier

Specified by:
get in interface IObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Parameters:
identifier -
Returns:
object or null

getIdentifiers

public java.util.Collection<IIdentifier> getIdentifiers()
return all the identifiers that have matched objects

Specified by:
getIdentifiers in interface IObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Returns:

contains

public boolean contains(IIdentifier identifier)
does this object manager have an object O that is keyed on this identifier

Parameters:
identifier -
Returns:

waitForChange

public void waitForChange()
                   throws java.lang.InterruptedException
Description copied from interface: IObjectManager
wait until something has been added, removed, updated

Specified by:
waitForChange in interface IObjectManager<O extends ISimulationObject,L extends IObjectListener<O>>
Throws:
java.lang.InterruptedException