Package jadex.future
Class CollectionResultListener<E>
java.lang.Object
jadex.future.CollectionResultListener<E>
- All Implemented Interfaces:
IResultListener<E>
,IUndoneResultListener<E>
public class CollectionResultListener<E>
extends Object
implements IResultListener<E>, IUndoneResultListener<E>
Collection result listener collects a number of results and return a collection.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IResultListener
<Collection<E>> The delegate result listener.protected boolean
Flag to indicate that failures should be ignored and only valid results returned.protected boolean
Flag to indicate that the delegate already has been notified.protected static final Object
Null object.protected int
The number of sub listeners to wait for.protected Collection
<E> The original result collection.protected boolean
The undone flag. -
Constructor Summary
ConstructorsConstructorDescriptionCollectionResultListener
(boolean ignorefailures, IResultListener<Collection<E>> delegate) Create a new collection listener.CollectionResultListener
(int num, boolean ignorefailures, IResultListener<Collection<E>> delegate) Create a new collection listener.CollectionResultListener
(int num, IResultListener<Collection<E>> delegate) Create a new collection listener that stops on failures.CollectionResultListener
(IResultListener<Collection<E>> delegate) Create a new collection listener that stops on failures. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkNotify
(E result, Exception ex) Check if the delegate should be notified.void
exceptionOccurred
(Exception exception) Called when an exception occurred.void
exceptionOccurredIfUndone
(Exception exception) Called when an exception occurred.int
Get the result count.boolean
isUndone()
Get the undone.protected void
notifyDelegate
(Exception exception) Notify the delegate.void
resultAvailable
(E result) Called when some result is available.void
resultAvailableIfUndone
(E result) Called when the result is available.void
setNumber
(int num) Set the expected number of results.
-
Field Details
-
num
protected int numThe number of sub listeners to wait for. -
results
The original result collection. -
delegate
The delegate result listener. -
notified
protected boolean notifiedFlag to indicate that the delegate already has been notified. -
ignorefailures
protected boolean ignorefailuresFlag to indicate that failures should be ignored and only valid results returned. -
undone
protected boolean undoneThe undone flag. -
NULL
Null object.
-
-
Constructor Details
-
CollectionResultListener
Create a new collection listener that stops on failures.- Parameters:
delegate
- The delegate result listener.
-
CollectionResultListener
Create a new collection listener.- Parameters:
ignorefailures
- When set to true failures will be tolerated and just not be added to the result collection.delegate
- The delegate result listener.
-
CollectionResultListener
Create a new collection listener that stops on failures.- Parameters:
num
- The expected number of results.delegate
- The delegate result listener.
-
CollectionResultListener
public CollectionResultListener(int num, boolean ignorefailures, IResultListener<Collection<E>> delegate) Create a new collection listener.- Parameters:
num
- The expected number of results.ignorefailures
- When set to true failures will be tolerated and just not be added to the result collection.delegate
- The delegate result listener.
-
-
Method Details
-
resultAvailable
Called when some 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.
-
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.
-
getResultCount
public int getResultCount()Get the result count.- Returns:
- The result count.
-
setNumber
public void setNumber(int num) Set the expected number of results.- Parameters:
num
- The expected number of results to set.
-
checkNotify
Check if the delegate should be notified. -
notifyDelegate
Notify the delegate.
-