cz.cuni.amis.pogamut.base.agent.navigation.impl
Class PrecomputedPathFuture<PATH_ELEMENT>

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.navigation.impl.PrecomputedPathFuture<PATH_ELEMENT>
Type Parameters:
PATH_ELEMENT -
All Implemented Interfaces:
IPathFuture<PATH_ELEMENT>, java.util.concurrent.Future<java.util.List<PATH_ELEMENT>>

public class PrecomputedPathFuture<PATH_ELEMENT>
extends java.lang.Object
implements IPathFuture<PATH_ELEMENT>

Serves as a IPathFuture that contains pre-set result, i.e., you do not need the future, you just want to pass down some value...


Constructor Summary
PrecomputedPathFuture(PATH_ELEMENT from, PATH_ELEMENT to, java.util.List<PATH_ELEMENT> path)
           
 
Method Summary
 void addFutureListener(IFutureListener<java.util.List<PATH_ELEMENT>> listener)
          Adds a listener on a future status (using strong reference).
 boolean cancel(boolean mayInterruptIfRunning)
           
 java.util.List<PATH_ELEMENT> get()
          First, see Future.get().
 java.util.List<PATH_ELEMENT> get(long timeout, java.util.concurrent.TimeUnit unit)
          Returns a path from IPathFuture.getPathFrom() to IPathFuture.getPathTo().
 PATH_ELEMENT getPathFrom()
          Where does the path start.
 PATH_ELEMENT getPathTo()
          Where does the path end.
 FutureStatus getStatus()
          Current status of the path computation.
 boolean isCancelled()
           
 boolean isDone()
           
 boolean isListening(IFutureListener<java.util.List<PATH_ELEMENT>> listener)
          Whether some listener is listening on the future.
 void removeFutureListener(IFutureListener<java.util.List<PATH_ELEMENT>> listener)
          Removes a listener from the future.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrecomputedPathFuture

public PrecomputedPathFuture(PATH_ELEMENT from,
                             PATH_ELEMENT to,
                             java.util.List<PATH_ELEMENT> path)
Method Detail

getPathFrom

public PATH_ELEMENT getPathFrom()
Description copied from interface: IPathFuture
Where does the path start. Note that this point might not be the first item of the path element list, this element marks the start location from which the planner has begun.

Specified by:
getPathFrom in interface IPathFuture<PATH_ELEMENT>
Returns:

getPathTo

public PATH_ELEMENT getPathTo()
Description copied from interface: IPathFuture
Where does the path end. Note that this point might not be the last item of the path element list, this element marks the end location to which the planner should plan the path.

Specified by:
getPathTo in interface IPathFuture<PATH_ELEMENT>
Returns:

addFutureListener

public void addFutureListener(IFutureListener<java.util.List<PATH_ELEMENT>> listener)
Description copied from interface: IPathFuture
Adds a listener on a future status (using strong reference). Listeners are automatically removed whenever the future gets its result (or is cancelled or an exception happens).

Specified by:
addFutureListener in interface IPathFuture<PATH_ELEMENT>

removeFutureListener

public void removeFutureListener(IFutureListener<java.util.List<PATH_ELEMENT>> listener)
Description copied from interface: IPathFuture
Removes a listener from the future.

Specified by:
removeFutureListener in interface IPathFuture<PATH_ELEMENT>

get

public java.util.List<PATH_ELEMENT> get()
Description copied from interface: IPathFuture
First, see Future.get().

May return null if no such path exist.

Throws some runtime exception if the path could not be computed (exact type of exception depends on the implementor of the interface).

Specified by:
get in interface IPathFuture<PATH_ELEMENT>
Specified by:
get in interface java.util.concurrent.Future<java.util.List<PATH_ELEMENT>>
Returns:
computed path

get

public java.util.List<PATH_ELEMENT> get(long timeout,
                                        java.util.concurrent.TimeUnit unit)
Description copied from interface: IPathFuture
Returns a path from IPathFuture.getPathFrom() to IPathFuture.getPathTo(). "From" is the first element of the path, "To" is the last element of the path.

First, see Future.get(long, TimeUnit).

May return null if no such path exist.

Throws some runtime exception if the path could not be computed (exact type of exception depends on the implementor of the interface).

Specified by:
get in interface IPathFuture<PATH_ELEMENT>
Specified by:
get in interface java.util.concurrent.Future<java.util.List<PATH_ELEMENT>>

getStatus

public FutureStatus getStatus()
Description copied from interface: IPathFuture
Current status of the path computation.

Specified by:
getStatus in interface IPathFuture<PATH_ELEMENT>
Returns:

isListening

public boolean isListening(IFutureListener<java.util.List<PATH_ELEMENT>> listener)
Description copied from interface: IPathFuture
Whether some listener is listening on the future.

Specified by:
isListening in interface IPathFuture<PATH_ELEMENT>
Returns:

cancel

public boolean cancel(boolean mayInterruptIfRunning)
Specified by:
cancel in interface java.util.concurrent.Future<java.util.List<PATH_ELEMENT>>

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface java.util.concurrent.Future<java.util.List<PATH_ELEMENT>>

isDone

public boolean isDone()
Specified by:
isDone in interface java.util.concurrent.Future<java.util.List<PATH_ELEMENT>>