Interface Future<V>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default Future<V> always​(ThrowingConsumer<Result<V>> consumer)
      Sets function to receive result of this Future, no matter if it succeeds or not.
      default V await()
      Blocks the current thread until this Future completes, and then either returns its value or throws its fault.
      default V await​(java.time.Duration timeout)
      Blocks the current thread either until this Future completes or the given timeout expires.
      default void cancel()
      Signals that the result of this Future no longer is of interest and that evaluation of the Future should be gracefully terminated.
      void cancel​(boolean mayInterruptIfRunning)
      Signals that the result of this Future no longer is of interest.
      default Future<V> delay​(java.time.Duration duration)
      Delays the result of this Future from the time it becomes available.
      default Future<V> delayUntil​(java.time.Instant baseline)
      Creates new Future that delays its completion until right after the given baseline.
      static <V> Future<V> done()
      Returns Future that always succeeds with null.
      default <U> Future<U> fail​(java.lang.Throwable throwable)
      Returns new Future that is guaranteed to fail with given throwable.
      static <V> Future<V> failure​(java.lang.Throwable fault)
      Creates new Future that always fails with fault.
      default <U> Future<U> flatMap​(ThrowingFunction<? super V,​? extends Future<U>> mapper)
      Returns new Future that is completed when the Future returned by mapper completes, which, in turn, is not executed until this Future completes.
      default <T extends java.lang.Throwable>
      Future<V>
      flatMapCatch​(java.lang.Class<T> class_, ThrowingFunction<T,​? extends Future<V>> mapper)
      Catches any fault produced by this Future that is assignable to class_ and uses mapper to transform it into a new value.
      default <T extends java.lang.Throwable>
      Future<V>
      flatMapFault​(java.lang.Class<T> class_, ThrowingFunction<java.lang.Throwable,​? extends Future<java.lang.Throwable>> mapper)
      Applies any fault produced by this Future to mapper, and then fails the returned future with the Throwable it returns.
      default <U> Future<U> flatMapResult​(ThrowingFunction<Result<V>,​? extends Future<U>> mapper)
      Returns new Future that is completed when the Future returned by mapper completes, which, in turn, is not executed until this Future completes.
      default Future<V> flatMapThrow​(ThrowingFunction<V,​? extends Future<? extends java.lang.Throwable>> mapper)
      Applies any value successfully produced by this Future to mapper, and then fails the returned future with the Throwable it returns.
      default Future<?> fork​(java.util.function.Consumer<V> consumer)
      Returns new Future that is completed successfully only if this Future completes successfully and its result can be provided to the given consumer function on a separate thread.
      default <U> Future<U> forkJoin​(ThrowingFunction<V,​U> mapper)
      Returns new Future that is completed after the value of this Future has become available and could be transformed into a value of type U by mapper on a separate thread.
      default <T extends java.lang.Throwable>
      Future<V>
      ifFailure​(java.lang.Class<T> class_, ThrowingConsumer<T> consumer)
      Sets function to receive result of this Future only if its operation fails.
      default Future<V> ifSuccess​(ThrowingConsumer<V> consumer)
      Sets function to receive result of this Future only if its operation succeeds.
      default <U> Future<U> map​(ThrowingFunction<? super V,​U> mapper)
      Returns new Future that is completed after the value of this Future has become available and could be transformed into a value of type U by mapper.
      default <T extends java.lang.Throwable>
      Future<V>
      mapCatch​(java.lang.Class<T> class_, ThrowingFunction<T,​? extends V> mapper)
      Catches any fault produced by this Future that is assignable to class_ and uses mapper to transform it into a new value.
      default <T extends java.lang.Throwable>
      Future<V>
      mapFault​(java.lang.Class<T> class_, ThrowingFunction<java.lang.Throwable,​java.lang.Throwable> mapper)
      Applies any fault produced by this Future that is assignable to class_ to mapper and then fails the returned future with the Throwable it returns.
      default <U> Future<U> mapResult​(ThrowingFunction<Result<V>,​Result<U>> mapper)
      Returns new Future that is completed after the value of this Future has become available and could be transformed into a result of type Result<U> by mapper.
      default <U> Future<U> mapThrow​(ThrowingFunction<? super V,​java.lang.Throwable> mapper)
      Takes any successful result produced by this Future and uses mapper to transform it into a fault.
      static <V> Future<V> of​(Result<V> result)
      Creates new Future that always completes with result.
      default void onFailure​(java.util.function.Consumer<java.lang.Throwable> consumer)
      Sets function to receive result of this Future only if its operation fails.
      void onResult​(java.util.function.Consumer<Result<V>> consumer)
      Sets function to receive result of this Future, when and if it becomes available.
      default <U> Future<U> pass​(U value)
      Returns new Future that succeeds with given value if this Future completes successfully.
      static <V> Future<V> success​(V value)
      Creates new Future that always succeeds with value.
      default FutureAnnouncement<V> toAnnouncement()
      Converts this Future into a FutureAnnouncement, which allows its result to be received by any number of subscribers.
    • Method Detail

      • onResult

        void onResult​(java.util.function.Consumer<Result<V>> consumer)
        Sets function to receive result of this Future, when and if it becomes available.

        If this method has been called previously on the same Future, any previously set consumer should be replaced by the one given. If a previous consumer has already been called when a new one is set, the new one might be called with the same result as the previous.

        The given consumer function should never throw exceptions that need to be handled explicitly. Any thrown exception will end up with the caller of the consumer, which is unlikely to be able to handle it in any other way than by logging it.

        Parameters:
        consumer - Function invoked when this Future completes.
        Throws:
        java.lang.NullPointerException - If consumer is null.
      • cancel

        void cancel​(boolean mayInterruptIfRunning)
        Signals that the result of this Future no longer is of interest.

        No guarantees whatsoever are given about the implications of this call. It may prevent onResult(Consumer) from being called, or may cause it to be called with a CancellationException, or something else entirely. However, the receiver of a Future that is no longer interested in its successful result should call this method to make it clear to the original issuer of the Future, unless a result has already been received.

        Parameters:
        mayInterruptIfRunning - Whether or not the thread executing the task associated with this Future, if any, should be interrupted. If not, in-progress tasks are allowed to complete. This parameter may be ignored.
      • cancel

        default void cancel()
        Signals that the result of this Future no longer is of interest and that evaluation of the Future should be gracefully terminated.

        No guarantees whatsoever are given about the implications of this call. It may prevent onResult(Consumer) from being called, or may cause it to be called with a CancellationException, or something else entirely. However, the receiver of a Future that is no longer interested in its successful result should call this method to make it clear to the original issuer of the Future, unless a result has already been received.

      • onFailure

        default void onFailure​(java.util.function.Consumer<java.lang.Throwable> consumer)
        Sets function to receive result of this Future only if its operation fails. Successful results are ignored.

        While it might seem like a logical addition, there is no corresponding #onValue(Consumer) method. The reason for this is that there is no reasonable default strategy for handling ignored faults. Silently discarding them is unlikely to be a suitable design choice, as it could hide details important for discovering or tracking application issues, and logging them would necessitate information about the context in which the successful result was required, as well as integration against a logging framework.

        Parameters:
        consumer - Function invoked if this Future completes with an fault.
        Throws:
        java.lang.NullPointerException - If consumer is null.
      • ifSuccess

        default Future<V> ifSuccess​(ThrowingConsumer<V> consumer)
        Sets function to receive result of this Future only if its operation succeeds. Successful or not, the result is also passed on to the returned Future.

        This method is primarily useful for triggering different kinds of side effects that become relevant only if an operation succeeds, such as logging or sending messages.

        Any exception thrown by consumer leads to the returned Future being failed with the same exception.

        Parameters:
        consumer - Function invoked if this Future completes successfully.
        Returns:
        New Future completed with the result of this Future.
        Throws:
        java.lang.NullPointerException - If consumer is null.
      • ifFailure

        default <T extends java.lang.Throwable> Future<V> ifFailure​(java.lang.Class<T> class_,
                                                                    ThrowingConsumer<T> consumer)
        Sets function to receive result of this Future only if its operation fails. Successful or not, the result is also passed on to the returned Future.

        This method is primarily useful for triggering different kinds of side effects that become relevant only if an operation fails, such as logging or sending messages.

        Any exception thrown by consumer leads to the returned Future being failed with the same exception. The exception that caused the consumer function to be called is added as a suppressed exception to the new exception thrown by the consumer function.

        Parameters:
        consumer - Function invoked if this Future completes with an fault.
        Returns:
        New Future completed with the result of this Future.
        Throws:
        java.lang.NullPointerException - If consumer is null.
      • always

        default Future<V> always​(ThrowingConsumer<Result<V>> consumer)
        Sets function to receive result of this Future, no matter if it succeeds or not. The result is also passed on to the returned Future.

        This method is primarily useful for triggering different kinds of side effects, such as logging or sending messages.

        Any exception thrown by consumer leads to the returned Future being failed with the same exception. If the result of this Future is a fault, that fault is added as a suppressed exception to the new exception thrown by the consumer function.

        Parameters:
        consumer - Function invoked with the result of this Future.
        Returns:
        New Future completed with the result of this Future.
        Throws:
        java.lang.NullPointerException - If consumer is null.
      • map

        default <U> Future<U> map​(ThrowingFunction<? super V,​U> mapper)
        Returns new Future that is completed after the value of this Future has become available and could be transformed into a value of type U by mapper.

        In other words, this method performs the asynchronous counterpart to the following code:

             V value0 = originalFutureOperation();
             // Wait for value0 to become available.
             U value1 = mapper.apply(value0);
             return value1;
         
        Any exception thrown by mapper leads to the returned Future being failed with the same exception.
        Type Parameters:
        U - The type of the value returned from the mapping function.
        Parameters:
        mapper - The mapping function to apply to the value of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the value of this Future, if it completes successfully.
        Throws:
        java.lang.NullPointerException - If mapper is null.
      • mapCatch

        default <T extends java.lang.Throwable> Future<V> mapCatch​(java.lang.Class<T> class_,
                                                                   ThrowingFunction<T,​? extends V> mapper)
        Catches any fault produced by this Future that is assignable to class_ and uses mapper to transform it into a new value.

        In other words, this method performs the asynchronous counterpart to the following code:

             try {
                 return originalFutureOperation();
             }
             catch (final U throwable) {
                 return mapper.apply(throwable);
             }
         
        Any exception thrown by mapper leads to the returned Future being failed with the same exception.
        Parameters:
        class_ - Class caught exceptions must be assignable to.
        mapper - The mapping function to apply to the fault of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the fault of this Future.
        Throws:
        java.lang.NullPointerException - If class_ or mapper is null.
      • mapFault

        default <T extends java.lang.Throwable> Future<V> mapFault​(java.lang.Class<T> class_,
                                                                   ThrowingFunction<java.lang.Throwable,​java.lang.Throwable> mapper)
        Applies any fault produced by this Future that is assignable to class_ to mapper and then fails the returned future with the Throwable it returns.

        In other words, this method performs the asynchronous counterpart to the following code:

             try {
                 return originalFutureOperation();
             }
             catch (final T throwable) {
                 throw mapper.apply(throwable);
             }
         
        Any exception thrown by mapper leads to the returned Future being failed with the same exception, meaning it is functionally equivalent to returning the exception.
        Parameters:
        mapper - The mapping function to apply to the fault of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the fault of this Future.
        Throws:
        java.lang.NullPointerException - If class_ or mapper is null.
      • mapResult

        default <U> Future<U> mapResult​(ThrowingFunction<Result<V>,​Result<U>> mapper)
        Returns new Future that is completed after the value of this Future has become available and could be transformed into a result of type Result<U> by mapper.

        In other words, this method performs the asynchronous counterpart to the following code:

             Result<V> result0 = originalFutureOperation();
             // Wait for result0 to become available.
             Result<U> result1 = mapper.apply(result0);
             return result1;
         
        Any exception thrown by mapper leads to the returned Future being failed with the same exception.
        Type Parameters:
        U - The type of the value returned from the mapping function.
        Parameters:
        mapper - The mapping function to apply to the value of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the value of this Future, if it completes successfully.
        Throws:
        java.lang.NullPointerException - If mapper is null.
      • mapThrow

        default <U> Future<U> mapThrow​(ThrowingFunction<? super V,​java.lang.Throwable> mapper)
        Takes any successful result produced by this Future and uses mapper to transform it into a fault.

        In other words, this method performs the asynchronous counterpart to the following code:

             V value = originalFutureOperation();
             // Wait for value to become available.
             Throwable fault = mapper.apply(value);
             throw fault;
         
        Any exception thrown by mapper leads to the returned Future being failed with the same exception.
        Parameters:
        mapper - The mapping function to apply to the value of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the value of this Future.
        Throws:
        java.lang.NullPointerException - If mapper is null.
      • flatMap

        default <U> Future<U> flatMap​(ThrowingFunction<? super V,​? extends Future<U>> mapper)
        Returns new Future that is completed when the Future returned by mapper completes, which, in turn, is not executed until this Future completes.

        The difference between this method and map(ThrowingFunction) is that the mapper provided here is expected to return a Future rather than a plain value. The returned Future completes after this Future and the Future returned by mapper have completed in sequence.

        In other words, this method performs the asynchronous counterpart to the following code:

             V value0 = originalFutureOperation();
             // Wait for value0 to become available.
             U value1 = mapper.apply(value0);
             // Wait for value1 to become available.
             return value1;
         
        Any exception thrown by mapper should lead to the returned future being failed with the same exception.
        Type Parameters:
        U - The type of the value returned from the mapping function.
        Parameters:
        mapper - The mapping function to apply to the value of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the value of this Future, and then waiting for the Future returned by the mapper to complete.
        Throws:
        java.lang.NullPointerException - If mapper is null.
      • flatMapCatch

        default <T extends java.lang.Throwable> Future<V> flatMapCatch​(java.lang.Class<T> class_,
                                                                       ThrowingFunction<T,​? extends Future<V>> mapper)
        Catches any fault produced by this Future that is assignable to class_ and uses mapper to transform it into a new value.

        The difference between this method and mapCatch(Class, ThrowingFunction) is that this method expects its mapper to return a Future rather than a plain value.

        In other words, this method performs the asynchronous counterpart to the following code:

             try {
                 return originalFutureOperation();
             }
             catch (final U throwable) {
                 V value = mapper.apply(throwable);
                 // Wait for new value to become available.
                 return value;
             }
         
        Any exception thrown by mapper leads to the returned Future being failed with the same exception.
        Parameters:
        class_ - Class that caught exceptions must be assignable to.
        mapper - The mapping function to apply to the fault of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the fault of this Future, and then waiting for the Future returned by the mapper to complete.
        Throws:
        java.lang.NullPointerException - If class_ or mapper is null.
      • flatMapFault

        default <T extends java.lang.Throwable> Future<V> flatMapFault​(java.lang.Class<T> class_,
                                                                       ThrowingFunction<java.lang.Throwable,​? extends Future<java.lang.Throwable>> mapper)
        Applies any fault produced by this Future to mapper, and then fails the returned future with the Throwable it returns.

        The difference between this method and mapFault(Class, ThrowingFunction) is that this method expects its mapper to return a Future<Throwable> rather than a plain Throwable.

        In other words, this method performs the asynchronous counterpart to the following code:

             try {
                 return originalFutureOperation();
             }
             catch (final T throwable) {
                 Throwable fault = mapper.apply(throwable);
                 // Wait for fault to become available.
                 throw fault;
             }
         
        Any exception thrown by mapper leads to the returned Future being failed with the same exception. Furthermore, if the Future returned by mapper fails, the Future returned by this method is failed with that exception.
        Parameters:
        mapper - The mapping function to apply to the fault of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the fault of this Future, and then waiting for the Future returned by the mapper to complete.
        Throws:
        java.lang.NullPointerException - If class_ or mapper is null.
      • flatMapResult

        default <U> Future<U> flatMapResult​(ThrowingFunction<Result<V>,​? extends Future<U>> mapper)
        Returns new Future that is completed when the Future returned by mapper completes, which, in turn, is not executed until this Future completes.

        The difference between this method and mapResult(ThrowingFunction) is that the mapper provided here is expected to return a Future rather than a plain result. The returned Future completes after this Future and the Future returned by mapper have completed in sequence.

        In other words, this method performs the asynchronous counterpart to the following code:

             Result<V> result0 = originalFutureOperation();
             // Wait for result0 to become available.
             U value1 = mapper.apply(result0);
             // Wait for value1 to become available.
             return value1;
         
        Any exception thrown by mapper should lead to the returned future being failed with the same exception.
        Type Parameters:
        U - The type of the value returned from the mapping function.
        Parameters:
        mapper - The mapping function to apply to the value of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the result of this Future, and then waiting for the Future returned by the mapper to complete.
        Throws:
        java.lang.NullPointerException - If mapper is null.
      • flatMapThrow

        default Future<V> flatMapThrow​(ThrowingFunction<V,​? extends Future<? extends java.lang.Throwable>> mapper)
        Applies any value successfully produced by this Future to mapper, and then fails the returned future with the Throwable it returns.

        The difference between this method and mapThrow(ThrowingFunction) is that this method expects its mapper to return a Future<Throwable> rather than a plain Throwable.

        In other words, this method performs the asynchronous counterpart to the following code:

                 V value = originalFutureOperation();
                 // Wait for value to become available.
                 Throwable fault = mapper.apply(value);
                 // Wait for fault to become available.
                 throw fault;
             }
         
        Any exception thrown by mapper leads to the returned Future being failed with the same exception. Furthermore, if the Future returned by mapper fails, the Future returned by this method is failed with that exception.
        Parameters:
        mapper - The mapping function to apply to the value of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the value of this Future, and then waiting for the Future returned by the mapper to complete.
        Throws:
        java.lang.NullPointerException - If mapper is null.
      • pass

        default <U> Future<U> pass​(U value)
        Returns new Future that succeeds with given value if this Future completes successfully.

        If this Future fails, on the other hand, the returned Future is failed with the same fault.

        Parameters:
        value - Value to include in the returned Future.
        Returns:
        A Future that will complete with given throwable as fault.
      • fail

        default <U> Future<U> fail​(java.lang.Throwable throwable)
        Returns new Future that is guaranteed to fail with given throwable.

        If this Future fails, its fault is added as a suppressed exception to the provided throwable. If this Future succeeds, its result is ignored.

        Parameters:
        throwable - Fault to include in returned Future.
        Returns:
        A Future that will complete with given throwable as fault.
        Throws:
        java.lang.NullPointerException - If throwable is null.
      • toAnnouncement

        default FutureAnnouncement<V> toAnnouncement()
        Converts this Future into a FutureAnnouncement, which allows its result to be received by any number of subscribers.

        As noted here, a Future should only ever present its result to a single receiver. This method allows for that scope be widened to zero or more receivers.

        Returns:
        FutureAnnouncement advertising the result of this Future to any number of subscribers.
      • delay

        default Future<V> delay​(java.time.Duration duration)
        Delays the result of this Future from the time it becomes available.
        Parameters:
        duration - Duration to delay the completion of this Future with.
        Returns:
        New Future that eventually completes with the result of this Future.
      • delayUntil

        default Future<V> delayUntil​(java.time.Instant baseline)
        Creates new Future that delays its completion until right after the given baseline.

        In other words, if this Future completes after the baseline, its result is passed on immediately by the returned Future. If, on the other hand, this Future completes before the baseline, the returned Future is scheduled for completion at some point right after that baseline.

        Parameters:
        baseline - Instant to delay result until, unless the result becomes available after that instant.
        Returns:
        New Future that eventually completes with the result of this Future.
      • fork

        default Future<?> fork​(java.util.function.Consumer<V> consumer)
        Returns new Future that is completed successfully only if this Future completes successfully and its result can be provided to the given consumer function on a separate thread.

        This method exists primarily as a means of helping prevent blocking calls from stalling threads in the default fixed scheduler, which has only a fixed number of threads. It should be used for long-running computations, blocking I/O, blocking database operations and other related kinds of use cases, but only when the result of the blocking operation will not be needed on the original thread from which it was forked. In that case, rather use the forkJoin method.

        It is the responsibility of the caller not to make any calls or execute any operations that may lead to race conditions. Note that only those Kalix library methods that are explicitly designated as thread-safe, using the @ThreadSafe annotation, can be safely called without explicit synchronization when accessed by multiple threads.

        Any exception thrown by consumer has no impact on the returned Future, but will be logged.

        Parameters:
        consumer - Function to invoke with successful result of this Future, if it ever becomes available.
        Returns:
        A Future that will be completed either with the fault of this Future or with null if the given consumer function could be executed on a separate thread.
      • forkJoin

        default <U> Future<U> forkJoin​(ThrowingFunction<V,​U> mapper)
        Returns new Future that is completed after the value of this Future has become available and could be transformed into a value of type U by mapper on a separate thread.

        In other words, this method performs exactly the same operation as the map method, but performs its execution on a separate thread. When computation finishes, the result is returned to the original thread and the returned future is completed. If, however, the thread completing this Future is not owned by the default fixed scheduler, this method will fail. This as the current thread is then not associated with a scheduler that can be accessed to schedule the joining of the fork without blocking.

        Unless otherwise noted, all Kalix methods returning Futures will always use the default fixed scheduler, which means that this method is then safe to use.

        This method exists primarily as a means of helping prevent blocking calls from stalling threads in the default fixed scheduler, which has only a fixed number of threads. It should be used for long-running computations, blocking I/O, blocking database operations and other related kinds of use cases.

        It is the responsibility of the caller not to make any calls or execute any operations that may lead to race conditions. Note that only those Kalix library methods that are explicitly designated as thread-safe, using the @ThreadSafe annotation, can be safely called without explicit synchronization when accessed by multiple threads.

        Any exception thrown by mapper leads to the returned Future being failed with the same exception.

        Type Parameters:
        U - The type of the value returned from the mapping function.
        Parameters:
        mapper - The mapping function to apply to the value of this Future, if it becomes available.
        Returns:
        A Future that may eventually hold the result of applying a mapping function to the value of this Future, if it completes successfully.
        Throws:
        java.lang.NullPointerException - If mapper is null.
      • await

        default V await()
                 throws java.lang.InterruptedException
        Blocks the current thread until this Future completes, and then either returns its value or throws its fault.

        Beware that awaiting a single Future more than once, either using this method or await(Duration), is not safe and is likely to result in deadlocks or stalls.

        Using this method injudiciously may result in severe performance issues.

        Returns:
        Value of this Future, if successful.
        Throws:
        java.lang.IllegalStateException - If this method is called from a thread that might fail to complete this Future if blocked.
        java.lang.InterruptedException - If the thread awaiting the completion of this Future would be interrupted.
      • await

        default V await​(java.time.Duration timeout)
                 throws java.lang.InterruptedException,
                        java.util.concurrent.TimeoutException
        Blocks the current thread either until this Future completes or the given timeout expires. If this Future completes before the timeout expires, its value or fault is returned or thrown, respectively.

        Beware that awaiting a single Future more than once, either using this method or await(), is not safe and is likely to result in deadlocks or stalls.

        Using this method injudiciously may result in severe performance issues.

        Parameters:
        timeout - Duration after which the waiting thread is no longer blocked and a TimeoutException, unless the result of this Future has become available.
        Returns:
        Value of this Future, if successful.
        Throws:
        java.lang.IllegalStateException - If this method is called from a thread that might fail to complete this Future if blocked.
        java.lang.InterruptedException - If the thread awaiting the completion of this Future would be interrupted.
        java.util.concurrent.TimeoutException
      • done

        static <V> Future<V> done()
        Returns Future that always succeeds with null.
        Returns:
        Cached Future.
      • success

        static <V> Future<V> success​(V value)
        Creates new Future that always succeeds with value.
        Type Parameters:
        V - Type of value.
        Parameters:
        value - Value to wrap in Future.
        Returns:
        New Future.
      • failure

        static <V> Future<V> failure​(java.lang.Throwable fault)
        Creates new Future that always fails with fault.
        Type Parameters:
        V - Type of value that would have been wrapped if successful.
        Parameters:
        fault - Error to wrap in Future.
        Returns:
        New Future.
      • of

        static <V> Future<V> of​(Result<V> result)
        Creates new Future that always completes with result.
        Type Parameters:
        V - Type of value that is being wrapped if result is successful.
        Parameters:
        result - Result to wrap in Future.
        Returns:
        New Future.