Class RunnablePromise<T>

java.lang.Object
org.smallibs.concurrent.promise.impl.SolvablePromise<T>
org.smallibs.concurrent.promise.impl.RunnablePromise<T>
All Implemented Interfaces:
Runnable, Promise<T>, Filter<Promise,T,Promise<T>>, HK<Promise,T,Promise<T>>

public final class RunnablePromise<T> extends SolvablePromise<T> implements Runnable
  • Constructor Details

    • RunnablePromise

      public RunnablePromise(Callable<T> callable)
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
    • createFuture

      protected SolvableFuture<T> createFuture(java.util.function.Consumer<Try<T>> callbackOnComplete)
      Overrides:
      createFuture in class SolvablePromise<T>
    • map

      public final <R> Promise<R> map(FunctionWithError<? super T,? extends R> function)
      Description copied from interface: Promise
      Method used to map a function. This mapping is done when the operation is a success. The result of this mapping is a new promise component.
      Specified by:
      map in interface Promise<T>
      Type Parameters:
      R - the promised value type
      Parameters:
      function - The function to apply on success which can raise an error
      Returns:
      a new promise
    • biMap

      public final <R> Promise<R> biMap(FunctionWithError<? super T,? extends R> onSuccess, FunctionWithError<? super Throwable,? extends R> onError)
      Description copied from interface: Promise
      Method used to map a function on success and another one on error. The result of this mapping is a new promise component.
      Specified by:
      biMap in interface Promise<T>
      Type Parameters:
      R - the promised value type
      Parameters:
      onSuccess - The function to apply on success which can raise an error
      onError - The function to apply on error which can also raise an error
      Returns:
      a new promise
    • flatmap

      public final <R> Promise<R> flatmap(java.util.function.Function<? super T,Promise<R>> function)
      Description copied from interface: Promise
      Method used to flatmap a function. This mapping is done when the operation is a success. The result of this mapping is a new promise component.
      Specified by:
      flatmap in interface Promise<T>
      Type Parameters:
      R - the promised value type
      Parameters:
      function - The function to apply on success
      Returns:
      a new promise
    • filter

      public final Promise<T> filter(java.util.function.Predicate<? super T> predicate)
      Description copied from interface: Filter
      Method called when the current data must be filtered using a given predicate.
      Specified by:
      filter in interface Filter<Promise,T,Promise<T>>
      Parameters:
      predicate - The filter
      Returns:
      a filtered data
    • self

      public final Promise<T> self()
      Specified by:
      self in interface HK<Promise,T,Promise<T>>