cz.cuni.amis.pogamut.base.communication.worldview.object
Class WorldObjectFuture<T extends IWorldObject>

Package class diagram package WorldObjectFuture
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.communication.worldview.object.WorldObjectFuture<T>
All Implemented Interfaces:
Future<T>

public class WorldObjectFuture<T extends IWorldObject>
extends Object
implements Future<T>

Use this if you want to wait for first appearance of some IWorldObject with known string ID.

Author:
ik

Nested Class Summary
static class WorldObjectFuture.WorldObjectFutureException
           
 
Constructor Summary
WorldObjectFuture(IWorldView worldView, Class<T> objectClass)
          Creates new instance of future that waits for first appearance of WorldObject of given class.
WorldObjectFuture(IWorldView worldView, String id, Class<T> objectClass)
          Creates new instance of future that waits for first appearance of WorldObject of given id.
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
           
protected  void customObjectEncounteredHook(T obj)
          Utility method for custom handling of the first-encounter event.
 T get()
           
 T get(long timeout, TimeUnit unit)
           
 boolean isCancelled()
           
 boolean isDone()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorldObjectFuture

public WorldObjectFuture(IWorldView worldView,
                         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 appear
objectClass - class of the object that will appear

WorldObjectFuture

public WorldObjectFuture(IWorldView worldView,
                         String id,
                         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 appear
id - string id of the object that will appear
objectClass - class of the object that will appear
Method Detail

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 Future<T extends IWorldObject>

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface Future<T extends IWorldObject>

isDone

public boolean isDone()
Specified by:
isDone in interface Future<T extends IWorldObject>

get

public T get()
Specified by:
get in interface Future<T extends IWorldObject>
Returns:
the object that was awaited
Throws:
InterruptedException
ExecutionException

get

public T get(long timeout,
             TimeUnit unit)
Specified by:
get in interface Future<T extends IWorldObject>


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.