Package jadex.future
Class CounterResultListener<E>
java.lang.Object
jadex.future.CounterResultListener<E>
- All Implemented Interfaces:
IResultListener<E>
,IUndoneResultListener<E>
public class CounterResultListener<E>
extends Object
implements IResultListener<E>, IUndoneResultListener<E>
Counter result listener for counting a specified number of resultAvailable calls.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The number of received callbacks.protected IResultListener
<Void> The delegate result listener.protected boolean
The ignore failure flag.protected boolean
Flag to indicate that the delegate already has been notified.protected int
The number of sub listeners to wait for.protected boolean
The undone flag. -
Constructor Summary
ConstructorsConstructorDescriptionCounterResultListener
(int num, boolean ignorefailures, IResultListener<Void> delegate) Create a new counter listener.CounterResultListener
(int num, IResultListener<Void> delegate) Create a new counter listener. -
Method Summary
Modifier and TypeMethodDescriptionvoid
exceptionOccurred
(Exception exception) Called when an exception occurred.void
exceptionOccurredIfUndone
(Exception exception) Called when an exception occurred.int
getCnt()
Get the current number of received results.int
Get the number of results this Listener is waiting for.boolean
intermediateExceptionOccurred
(Exception exception) Method that can be overridden to do sth.void
intermediateResultAvailable
(E result) Method that can be overridden to do sth.boolean
isUndone()
Get the undone.void
resultAvailable
(E result) Called when the result is available.void
resultAvailableIfUndone
(E result) Called when the result is available.void
setNumber
(int num) Set the number.
-
Field Details
-
num
protected int numThe number of sub listeners to wait for. -
cnt
protected int cntThe number of received callbacks. -
delegate
The delegate result listener. -
notified
protected boolean notifiedFlag to indicate that the delegate already has been notified. -
ignorefailures
protected boolean ignorefailuresThe ignore failure flag. -
undone
protected boolean undoneThe undone flag.
-
-
Constructor Details
-
CounterResultListener
Create a new counter listener.- Parameters:
num
- The number of sub callbacks.
-
CounterResultListener
Create a new counter listener.- Parameters:
num
- The number of sub callbacks.
-
-
Method Details
-
resultAvailable
Called when the result is available.- Specified by:
resultAvailable
in interfaceIResultListener<E>
- Parameters:
result
- The result.
-
exceptionOccurred
Called when an exception occurred.- Specified by:
exceptionOccurred
in interfaceIResultListener<E>
- Parameters:
exception
- The exception.
-
intermediateResultAvailable
Method that can be overridden to do sth. on each result available call. -
intermediateExceptionOccurred
Method that can be overridden to do sth. on each exception that occurs.- Returns:
- True, for retry the task (cnt is not increased);
-
getNumber
public int getNumber()Get the number of results this Listener is waiting for.- Returns:
- The expected number of results.
-
setNumber
public void setNumber(int num) Set the number.- Parameters:
num
- The number.
-
getCnt
public int getCnt()Get the current number of received results.- Returns:
- Number of results.
-
resultAvailableIfUndone
Called when the result is available.- Specified by:
resultAvailableIfUndone
in interfaceIUndoneResultListener<E>
- Parameters:
result
- The result.
-
exceptionOccurredIfUndone
Called when an exception occurred.- Specified by:
exceptionOccurredIfUndone
in interfaceIUndoneResultListener<E>
- Parameters:
exception
- The exception.
-
isUndone
public boolean isUndone()Get the undone.- Returns:
- The undone.
-