Package jadex.commons.future
Class TerminableFuture<E>
- java.lang.Object
- 
- jadex.commons.future.Future<E>
- 
- jadex.commons.future.TerminableFuture<E>
 
 
- 
- All Implemented Interfaces:
- IBackwardCommandFuture,- IForwardCommandFuture,- IFuture<E>,- ITerminableFuture<E>
 
 public class TerminableFuture<E> extends Future<E> implements ITerminableFuture<E> Future that can be terminated from caller side. A termination request leads to setException() being called with a FutureTerminatedException. The future can be supplied with a command that gets executed if terminate is called.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface jadex.commons.future.IForwardCommandFutureIForwardCommandFuture.Type
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected java.util.Map<ICommand<java.lang.Object>,IFilter<java.lang.Object>>bcommandsThe list of backward commands.protected ITerminationCommandterminateThe termination code.- 
Fields inherited from class jadex.commons.future.FutureCALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, first, listener, listeners, NO_STACK_COMPACTION, NONE, notcommand, notifications, result, resultavailable, STACK, undone, UNSET
 
- 
 - 
Constructor SummaryConstructors Constructor Description TerminableFuture()Create a new future.TerminableFuture(ITerminationCommand terminate)Create a future that is already done.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBackwardCommand(IFilter<java.lang.Object> filter, ICommand<java.lang.Object> command)Add a backward command with a filter.voidremoveBackwardCommand(ICommand<java.lang.Object> command)Add a command with a filter.voidsendBackwardCommand(java.lang.Object info)Send a backward command in direction of the source.voidsetTerminationCommand(ITerminationCommand terminate)Set the termination command.voidterminate()Terminate the future.voidterminate(java.lang.Exception reason)Terminate the future and supply a custom reason.- 
Methods inherited from class jadex.commons.future.FutureabortGet, addResultListener, catchErr, catchErr, catchErr, delegate, doSetException, doSetResult, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, getNotificationCommand, hasResultListener, isDone, notifyListener, notifyListener, resume, scheduleNotification, scheduleNotification, scheduleNotification, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, startScheduledNotifications, then, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface jadex.commons.future.IFutureaddResultListener, catchErr, catchErr, catchErr, delegate, get, get, get, get, get, getException, isDone, then, thenApply, thenApply, thenCompose, thenCompose
 
- 
 
- 
- 
- 
Field Detail- 
terminateprotected ITerminationCommand terminate The termination code.
 
- 
 - 
Constructor Detail- 
TerminableFuturepublic TerminableFuture() Create a new future.
 - 
TerminableFuturepublic TerminableFuture(ITerminationCommand terminate) Create a future that is already done.- Parameters:
- result- The result, if any.
 
 
- 
 - 
Method Detail- 
terminatepublic void terminate() Terminate the future. The exception will be set to FutureTerminatedException.- Specified by:
- terminatein interface- ITerminableFuture<E>
 
 - 
terminatepublic void terminate(java.lang.Exception reason) Terminate the future and supply a custom reason.- Specified by:
- terminatein interface- ITerminableFuture<E>
 
 - 
sendBackwardCommandpublic void sendBackwardCommand(java.lang.Object info) Send a backward command in direction of the source.- Specified by:
- sendBackwardCommandin interface- IBackwardCommandFuture
- Parameters:
- info- The command info.
 
 - 
addBackwardCommandpublic void addBackwardCommand(IFilter<java.lang.Object> filter, ICommand<java.lang.Object> command) Add a backward command with a filter. Whenever the future receives an info it will check all registered filters.
 - 
removeBackwardCommandpublic void removeBackwardCommand(ICommand<java.lang.Object> command) Add a command with a filter. Whenever the future receives an info it will check all registered filters.
 - 
setTerminationCommandpublic void setTerminationCommand(ITerminationCommand terminate) Set the termination command.- Parameters:
- terminate- The termination command.
 
 
- 
 
-