Package jadex.future

Class IntermediateExceptionDelegationResultListener<E,T>

java.lang.Object
jadex.future.IntermediateExceptionDelegationResultListener<E,T>
All Implemented Interfaces:
IFutureCommandResultListener<Collection<E>>, IIntermediateResultListener<E>, IResultListener<Collection<E>>, IUndoneIntermediateResultListener<E>, IUndoneResultListener<Collection<E>>

public class IntermediateExceptionDelegationResultListener<E,T> extends Object implements IIntermediateResultListener<E>, IFutureCommandResultListener<Collection<E>>, IUndoneIntermediateResultListener<E>
Exception delegation listener for intermediate futures.
  • Field Details

    • future

      protected Future<T> future
      The future to which calls are delegated.
    • undone

      protected boolean undone
      The undone flag.
    • irlistener

      protected Consumer<E> irlistener
      Custom functional result listener
    • flistener

      protected Runnable flistener
      Custom functional finished listener
    • clistener

      protected Consumer<Integer> clistener
      Custom functional result count listener.
  • Constructor Details

    • IntermediateExceptionDelegationResultListener

      public IntermediateExceptionDelegationResultListener(Future<T> future, Consumer<E> irlistener, Runnable flistener, Consumer<Integer> clistener)
      Create a new listener.
      Parameters:
      future - The delegation target.
      irlistener - Functional intermediate result Listener. Can be null.
      flistener - Functional finished listener. Can be null.
    • IntermediateExceptionDelegationResultListener

      public IntermediateExceptionDelegationResultListener(Future<T> future)
      Create a new listener.
  • Method Details

    • resultAvailable

      public void resultAvailable(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 interface IResultListener<E>
      Parameters:
      result - The final result.
    • intermediateResultAvailable

      public void intermediateResultAvailable(E result)
      Called when an intermediate result is available.
      Specified by:
      intermediateResultAvailable in interface IIntermediateResultListener<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 interface IIntermediateResultListener<E>
    • customResultAvailable

      public void customResultAvailable(Collection<E> result)
      Called when the result is available.
      Parameters:
      result - The result.
    • exceptionOccurred

      public void exceptionOccurred(Exception exception)
      Called when an exception occurred.
      Specified by:
      exceptionOccurred in interface IResultListener<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 interface IIntermediateResultListener<E>
    • resultAvailableIfUndone

      public void resultAvailableIfUndone(Collection<E> result)
      Called when the result is available.
      Specified by:
      resultAvailableIfUndone in interface IUndoneResultListener<E>
      Parameters:
      result - The result.
    • exceptionOccurredIfUndone

      public void exceptionOccurredIfUndone(Exception exception)
      Called when an exception occurred.
      Specified by:
      exceptionOccurredIfUndone in interface IUndoneResultListener<E>
      Parameters:
      exception - The exception.
    • intermediateResultAvailableIfUndone

      public void intermediateResultAvailableIfUndone(E result)
      Called when an intermediate result is available.
      Specified by:
      intermediateResultAvailableIfUndone in interface IUndoneIntermediateResultListener<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 interface IUndoneIntermediateResultListener<E>
    • commandAvailable

      public void commandAvailable(Object command)
      Called when a command is available.
      Specified by:
      commandAvailable in interface IFutureCommandResultListener<E>
    • isUndone

      public boolean isUndone()
      Get the undone.
      Returns:
      The undone.