Package jadex.commons.future
Class SResultListener
- java.lang.Object
-
- jadex.commons.future.SResultListener
-
public class SResultListener extends java.lang.Object
Static helper class for creating result listeners.
-
-
Constructor Summary
Constructors Constructor Description SResultListener()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> CounterResultListener<E>
countResults(int num, IFunctionalResultListener<java.lang.Void> countReachedListener)
Creates anCounterResultListener
.static <E> CounterResultListener<E>
countResults(int num, IFunctionalResultListener<java.lang.Void> countReachedListener, IFunctionalExceptionListener exListener)
Creates anCounterResultListener
.static <E> CounterResultListener<E>
countResults(int num, IFunctionalResultListener<java.lang.Void> countReachedListener, IFunctionalResultListener<E> intermediateListener, IFunctionalExceptionListener exListener)
Creates anCounterResultListener
.static <E> IResultListener<E>
createResultListener(IFunctionalResultListener<E> sucListener)
Creates anIResultListener
that delegates results to the given SuccessListener and uses default exception handling.static <E> IResultListener<E>
createResultListener(IFunctionalResultListener<E> sucListener, boolean defaultExceptionHandling)
Creates anIResultListener
that delegates results to the given SuccessListener.static <E> IResultListener<E>
createResultListener(IFunctionalResultListener<E> sucListener, IFunctionalExceptionListener exceptionListener)
Creates anIResultListener
that delegates results to the given SuccessListener and Exceptions to the given ExceptionListener.static <E> IResultListener<E>
delegate(Future<E> delegate)
Creates anIResultListener
that delegates results and exceptions to a given Future.static <E> IResultListener<E>
delegate(Future<E> delegate, boolean undone)
Creates anIResultListener
that delegates results and exceptions to a given Future.static <E> IResultListener<E>
delegate(Future<E> delegate, boolean undone, IFunctionalResultListener<E> customResultListener)
Creates anIResultListener
that delegates results and exceptions to a given Future.static <E> IResultListener<E>
delegate(Future<E> delegate, IFunctionalResultListener<E> customResultListener)
Creates anIResultListener
that delegates results and exceptions to a given Future.static <E> IIntermediateResultListener<E>
delegate(IntermediateFuture<E> delegate)
Creates anIIntermediateResultListener
that delegates results and exceptions to a given IntermediateFuture.static <E> IIntermediateResultListener<E>
delegate(IntermediateFuture<E> delegate, boolean undone)
Creates anIIntermediateResultListener
that delegates results and exceptions to a given IntermediateFuture.static <E> IIntermediateResultListener<E>
delegate(IntermediateFuture<E> delegate, boolean undone, IFunctionalResultListener<java.util.Collection<E>> customResultListener, IFunctionalIntermediateResultListener<E> customIntermediateResultListener)
Creates anIIntermediateResultListener
that delegates results and exceptions to a given IntermediateFuture.static <E,F>
ITuple2ResultListener<E,F>delegate(Tuple2Future<E,F> delegate)
Creates anITuple2ResultListener
that delegates results and exceptions to a given Future.static <E,T>
IResultListener<E>delegateExceptions(Future<T> delegate, boolean undone, IFunctionalResultListener<E> customResultListener)
Creates anIResultListener
that delegates exceptions to a given Future and results to a given SuccessListener.static <E,T>
IResultListener<E>delegateExceptions(Future<T> delegate, IFunctionalResultListener<E> customResultListener)
Creates anIResultListener
that delegates exceptions to a given Future and results to a given SuccessListener.static <E> void
delegateFromTo(IFuture<E> source, Future<E> target)
Creates a delegation from source to target, respecting future types.static IFunctionalExceptionListener
ignoreExceptions()
Returns an OnExceptionListener that ignores all results.static <E> IFunctionalResultListener<E>
ignoreResults()
Returns a SuccessListener that ignores all results.static IFunctionalExceptionListener
printExceptions()
Returns an OnExceptionListener that logs exceptions to console.
-
-
-
Method Detail
-
ignoreResults
public static final <E> IFunctionalResultListener<E> ignoreResults()
Returns a SuccessListener that ignores all results.- Returns:
IFunctionalResultListener
-
ignoreExceptions
public static final IFunctionalExceptionListener ignoreExceptions()
Returns an OnExceptionListener that ignores all results.- Returns:
IFunctionalExceptionListener
-
printExceptions
public static final IFunctionalExceptionListener printExceptions()
Returns an OnExceptionListener that logs exceptions to console.- Returns:
IFunctionalExceptionListener
-
delegateFromTo
public static <E> void delegateFromTo(IFuture<E> source, Future<E> target)
Creates a delegation from source to target, respecting future types.- Parameters:
source
- Delegation source.target
- Delegation target.
-
delegate
public static <E> IResultListener<E> delegate(Future<E> delegate)
Creates anIResultListener
that delegates results and exceptions to a given Future. Supports creating delegations for Future, IntermediateFuture and Tuple2Future.- Parameters:
delegate
- The future used for success delegation.- Returns:
IResultListener
-
delegate
public static <E> IResultListener<E> delegate(Future<E> delegate, boolean undone)
Creates anIResultListener
that delegates results and exceptions to a given Future.- Parameters:
delegate
- The future used for success delegation.undone
- Flag if undone methods should be used.- Returns:
IResultListener
-
delegate
public static <E> IResultListener<E> delegate(Future<E> delegate, IFunctionalResultListener<E> customResultListener)
Creates anIResultListener
that delegates results and exceptions to a given Future.- Parameters:
delegate
- The future used for success delegation.customResultListener
- Custom result listener that overwrites the delegation behaviour.- Returns:
IResultListener
-
delegate
public static <E> IResultListener<E> delegate(Future<E> delegate, boolean undone, IFunctionalResultListener<E> customResultListener)
Creates anIResultListener
that delegates results and exceptions to a given Future.- Parameters:
delegate
- The future used for success delegation.undone
- Flag if undone methods should be used.customResultListener
- Custom result listener that overwrites the delegation behaviour.- Returns:
IResultListener
-
delegate
public static <E> IIntermediateResultListener<E> delegate(IntermediateFuture<E> delegate)
Creates anIIntermediateResultListener
that delegates results and exceptions to a given IntermediateFuture.- Parameters:
delegate
- The future used for intermediate and final result delegation.- Returns:
IntermediateDelegationResultListener
-
delegate
public static <E> IIntermediateResultListener<E> delegate(IntermediateFuture<E> delegate, boolean undone)
Creates anIIntermediateResultListener
that delegates results and exceptions to a given IntermediateFuture.- Parameters:
delegate
- The future used for intermediate and final result delegation.undone
- Flag if undone methods should be used.- Returns:
IntermediateDelegationResultListener
-
delegate
public static <E> IIntermediateResultListener<E> delegate(IntermediateFuture<E> delegate, boolean undone, IFunctionalResultListener<java.util.Collection<E>> customResultListener, IFunctionalIntermediateResultListener<E> customIntermediateResultListener)
Creates anIIntermediateResultListener
that delegates results and exceptions to a given IntermediateFuture.- Parameters:
delegate
- The future used for intermediate and final result delegation.undone
- Flag if undone methods should be used.customResultListener
- Custom result listener that overwrites the delegation behaviour.customIntermediateResultListener
- Custom intermediate result listener that overwrites the delegation behaviour.- Returns:
IntermediateDelegationResultListener
-
delegate
public static <E,F> ITuple2ResultListener<E,F> delegate(Tuple2Future<E,F> delegate)
Creates anITuple2ResultListener
that delegates results and exceptions to a given Future. Supports creating delegations for Tuple2Future.- Parameters:
delegate
- The future used for success delegation.- Returns:
IResultListener
-
delegateExceptions
public static <E,T> IResultListener<E> delegateExceptions(Future<T> delegate, IFunctionalResultListener<E> customResultListener)
Creates anIResultListener
that delegates exceptions to a given Future and results to a given SuccessListener.- Parameters:
delegate
- The future used for exception delegation.customResultListener
- The SuccessListener.- Returns:
IResultListener
-
delegateExceptions
public static <E,T> IResultListener<E> delegateExceptions(Future<T> delegate, boolean undone, IFunctionalResultListener<E> customResultListener)
Creates anIResultListener
that delegates exceptions to a given Future and results to a given SuccessListener.- Parameters:
delegate
- The future used for exception delegation.undone
- Flag if undone methods should be used.customResultListener
- The SuccessListener.- Returns:
IResultListener
-
countResults
public static <E> CounterResultListener<E> countResults(int num, IFunctionalResultListener<java.lang.Void> countReachedListener)
Creates anCounterResultListener
.- Parameters:
num
- The number of sub callbacks.countReachedListener
- Listener to be called when the given number is reached.- Returns:
CounterResultListener
-
countResults
public static <E> CounterResultListener<E> countResults(int num, IFunctionalResultListener<java.lang.Void> countReachedListener, IFunctionalExceptionListener exListener)
Creates anCounterResultListener
.- Parameters:
num
- The number of sub callbacks.countReachedListener
- Listener to be called when the given number is reached.exListener
- Listener to be called for exceptions.- Returns:
CounterResultListener
-
countResults
public static <E> CounterResultListener<E> countResults(int num, IFunctionalResultListener<java.lang.Void> countReachedListener, IFunctionalResultListener<E> intermediateListener, IFunctionalExceptionListener exListener)
Creates anCounterResultListener
.- Parameters:
num
- The number of sub callbacks.countReachedListener
- Listener to be called when the given number is reached.intermediateListener
- Listener to be called for intermediate Results.exListener
- Listener to be called for exceptions.- Returns:
CounterResultListener
-
createResultListener
public static <E> IResultListener<E> createResultListener(IFunctionalResultListener<E> sucListener)
Creates anIResultListener
that delegates results to the given SuccessListener and uses default exception handling.- Parameters:
sucListener
- The SuccessListener.- Returns:
IResultListener
-
createResultListener
public static <E> IResultListener<E> createResultListener(IFunctionalResultListener<E> sucListener, boolean defaultExceptionHandling)
Creates anIResultListener
that delegates results to the given SuccessListener.- Parameters:
sucListener
- The SuccessListener.defaultExceptionHandling
- Specifies whether to use a default handling for exceptions or not.- Returns:
IResultListener
-
createResultListener
public static <E> IResultListener<E> createResultListener(IFunctionalResultListener<E> sucListener, IFunctionalExceptionListener exceptionListener)
Creates anIResultListener
that delegates results to the given SuccessListener and Exceptions to the given ExceptionListener.- Parameters:
sucListener
- The SuccessListener.exceptionListener
- The ExceptionListener. Ifnull
, exceptions are logged.- Returns:
IResultListener
-
-