cz.cuni.amis.pogamut.base.communication.worldview.object
Class WorldObjectFuture<T extends IWorldObject>
java.lang.Object
cz.cuni.amis.pogamut.base.communication.worldview.object.WorldObjectFuture<T>
- All Implemented Interfaces:
- java.util.concurrent.Future<T>
public class WorldObjectFuture<T extends IWorldObject>
- extends java.lang.Object
- implements java.util.concurrent.Future<T>
Use this if you want to wait for first appearance of some IWorldObject with known string ID.
Constructor Summary |
WorldObjectFuture(IWorldView worldView,
java.lang.Class<T> objectClass)
Creates new instance of future that waits for first appearance of WorldObject
of given class. |
WorldObjectFuture(IWorldView worldView,
java.lang.String id,
java.lang.Class<T> objectClass)
Creates new instance of future that waits for first appearance of WorldObject
of given id. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WorldObjectFuture
public WorldObjectFuture(IWorldView worldView,
java.lang.Class<T> objectClass)
- Creates new instance of future that waits for first appearance of WorldObject
of given class.
- Parameters:
worldView
- WorldView where the object will appearobjectClass
- class of the object that will appear
WorldObjectFuture
public WorldObjectFuture(IWorldView worldView,
java.lang.String id,
java.lang.Class<T> objectClass)
- Creates new instance of future that waits for first appearance of WorldObject
of given id.
- Parameters:
worldView
- WorldView where the object will appearid
- string id of the object that will appearobjectClass
- class of the object that will appear
customObjectEncounteredHook
protected void customObjectEncounteredHook(T obj)
- Utility method for custom handling of the first-encounter event.
- Parameters:
obj
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interface java.util.concurrent.Future<T extends IWorldObject>
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interface java.util.concurrent.Future<T extends IWorldObject>
isDone
public boolean isDone()
- Specified by:
isDone
in interface java.util.concurrent.Future<T extends IWorldObject>
get
public T get()
- Specified by:
get
in interface java.util.concurrent.Future<T extends IWorldObject>
- Returns:
- the object that was awaited
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
get
public T get(long timeout,
java.util.concurrent.TimeUnit unit)
- Specified by:
get
in interface java.util.concurrent.Future<T extends IWorldObject>