Package jadex.commons.future
Class IntermediateExceptionDelegationResultListener<E,T>
- java.lang.Object
-
- jadex.commons.future.IntermediateExceptionDelegationResultListener<E,T>
-
- All Implemented Interfaces:
IFutureCommandResultListener<java.util.Collection<E>>
,IIntermediateResultListener<E>
,IResultListener<java.util.Collection<E>>
,IUndoneIntermediateResultListener<E>
,IUndoneResultListener<java.util.Collection<E>>
public class IntermediateExceptionDelegationResultListener<E,T> extends java.lang.Object implements IIntermediateResultListener<E>, IFutureCommandResultListener<java.util.Collection<E>>, IUndoneIntermediateResultListener<E>
Exception delegation listener for intermediate futures.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.Consumer<java.lang.Integer>
clistener
Custom functional result count listener.protected java.lang.Runnable
flistener
Custom functional finished listenerprotected Future<T>
future
The future to which calls are delegated.protected java.util.function.Consumer<E>
irlistener
Custom functional result listenerprotected boolean
undone
The undone flag.
-
Constructor Summary
Constructors Constructor Description IntermediateExceptionDelegationResultListener(Future<T> future)
Create a new listener.IntermediateExceptionDelegationResultListener(Future<T> future, java.util.function.Consumer<E> irlistener, java.lang.Runnable flistener, java.util.function.Consumer<java.lang.Integer> clistener)
Create a new listener.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commandAvailable(java.lang.Object command)
Called when a command is available.void
customResultAvailable(java.util.Collection<E> result)
Called when the result is available.void
exceptionOccurred(java.lang.Exception exception)
Called when an exception occurred.void
exceptionOccurredIfUndone(java.lang.Exception exception)
Called when an exception occurred.void
finished()
Declare that the future is finished.void
finishedIfUndone()
Declare that the future is finished.void
intermediateResultAvailable(E result)
Called when an intermediate result is available.void
intermediateResultAvailableIfUndone(E result)
Called when an intermediate result is available.boolean
isUndone()
Get the undone.void
maxResultCountAvailable(int max)
Declare that the future result count is available.void
resultAvailable(java.util.Collection<E> result)
Called when the result is available.void
resultAvailableIfUndone(java.util.Collection<E> result)
Called when the result is available.
-
-
-
Field Detail
-
undone
protected boolean undone
The undone flag.
-
irlistener
protected java.util.function.Consumer<E> irlistener
Custom functional result listener
-
flistener
protected java.lang.Runnable flistener
Custom functional finished listener
-
clistener
protected java.util.function.Consumer<java.lang.Integer> clistener
Custom functional result count listener.
-
-
Constructor Detail
-
IntermediateExceptionDelegationResultListener
public IntermediateExceptionDelegationResultListener(Future<T> future, java.util.function.Consumer<E> irlistener, java.lang.Runnable flistener, java.util.function.Consumer<java.lang.Integer> clistener)
Create a new listener.- Parameters:
future
- The delegation target.irlistener
- Functional intermediate result Listener. Can benull
.flistener
- Functional finished listener. Can benull
.
-
-
Method Detail
-
resultAvailable
public void resultAvailable(java.util.Collection<E> result)
Called when the result is available. This method is only called for non-intermediate futures, i.e. when this method is called it is guaranteed that the intermediateResultAvailable method has not been called.- Specified by:
resultAvailable
in interfaceIResultListener<E>
- Parameters:
result
- The final result.
-
intermediateResultAvailable
public void intermediateResultAvailable(E result)
Called when an intermediate result is available.- Specified by:
intermediateResultAvailable
in interfaceIIntermediateResultListener<E>
- Parameters:
result
- The result.
-
finished
public void finished()
Declare that the future is finished. This method is only called for intermediate futures, i.e. when this method is called it is guaranteed that the intermediateResultAvailable method was called for all intermediate results before.- Specified by:
finished
in interfaceIIntermediateResultListener<E>
-
customResultAvailable
public void customResultAvailable(java.util.Collection<E> result)
Called when the result is available.- Parameters:
result
- The result.
-
exceptionOccurred
public void exceptionOccurred(java.lang.Exception exception)
Called when an exception occurred.- Specified by:
exceptionOccurred
in interfaceIResultListener<E>
- Parameters:
exception
- The exception.
-
maxResultCountAvailable
public void maxResultCountAvailable(int max)
Description copied from interface:IIntermediateResultListener
Declare that the future result count is available. This method is only called for intermediate futures, i.e. when this method is called it is guaranteed that the intermediateResultAvailable method will be called as often as the result count indicates except an exception occurs.- Specified by:
maxResultCountAvailable
in interfaceIIntermediateResultListener<E>
-
resultAvailableIfUndone
public void resultAvailableIfUndone(java.util.Collection<E> result)
Called when the result is available.- Specified by:
resultAvailableIfUndone
in interfaceIUndoneResultListener<E>
- Parameters:
result
- The result.
-
exceptionOccurredIfUndone
public void exceptionOccurredIfUndone(java.lang.Exception exception)
Called when an exception occurred.- Specified by:
exceptionOccurredIfUndone
in interfaceIUndoneResultListener<E>
- Parameters:
exception
- The exception.
-
intermediateResultAvailableIfUndone
public void intermediateResultAvailableIfUndone(E result)
Called when an intermediate result is available.- Specified by:
intermediateResultAvailableIfUndone
in interfaceIUndoneIntermediateResultListener<E>
- Parameters:
result
- The result.
-
finishedIfUndone
public void finishedIfUndone()
Declare that the future is finished. This method is only called for intermediate futures, i.e. when this method is called it is guaranteed that the intermediateResultAvailable method was called for all intermediate results before.- Specified by:
finishedIfUndone
in interfaceIUndoneIntermediateResultListener<E>
-
commandAvailable
public void commandAvailable(java.lang.Object command)
Called when a command is available.- Specified by:
commandAvailable
in interfaceIFutureCommandResultListener<E>
-
isUndone
public boolean isUndone()
Get the undone.- Returns:
- The undone.
-
-