Class ResultFuture<R>

java.lang.Object
ch.nolix.base.programcontrol.future.AbstractFuture
ch.nolix.base.programcontrol.flowcontrol.ResultFuture<R>
Type Parameters:
R - is the type of the result of a ResultFuture.
All Implemented Interfaces:
IFuture, IResultFuture<R>, FinishRequestable

public final class ResultFuture<R> extends AbstractFuture implements IResultFuture<R>
Author:
Silvan Wyss
  • Method Details

    • forResultJobExecutor

      public static <T> ResultFuture<T> forResultJobExecutor(ch.nolix.base.programcontrol.flowcontrol.ResultJobExecutor<T> resultJobExecutor)
      Type Parameters:
      T - is the type of the result of created ResultFuture.
      Parameters:
      resultJobExecutor -
      Returns:
      a new ResultFuture with the given resultJobExecutor.
      Throws:
      RuntimeException - if the given resultJobExecutor is null.
    • caughtError

      public boolean caughtError()
      Specified by:
      caughtError in interface IFuture
      Returns:
      true if the current IFuture caught an error, false otherwise.
    • getError

      public Throwable getError()
      Specified by:
      getError in interface IFuture
      Returns:
      the error of the current IFuture.
    • getResult

      public R getResult()
      Specified by:
      getResult in interface IResultFuture<R>
      Returns:
      the result of the current IResultFuture.
    • isFinished

      public boolean isFinished()
      Specified by:
      isFinished in interface FinishRequestable
      Returns:
      true if the current FinishRequestable is finished, false otherwise.
    • waitUntilIsFinished

      public void waitUntilIsFinished()
      Lets the current IFuture wait until it is finished.
      Specified by:
      waitUntilIsFinished in interface IFuture
    • waitUntilIsFinished

      public void waitUntilIsFinished(int timeoutInMilliseconds)
      Lets the current IFuture wait until it is finished within the given timeoutInMilliseconds.
      Specified by:
      waitUntilIsFinished in interface IFuture
      Parameters:
      timeoutInMilliseconds -
    • waitUntilIsFinishedAndGetResult

      public R waitUntilIsFinishedAndGetResult()
      Waits until the current IResultFuture is finished and returns its result.
      Specified by:
      waitUntilIsFinishedAndGetResult in interface IResultFuture<R>
      Returns:
      the result of the current IResultFuture after waiting until it is finished.