Class SolvedPromise<T>

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

public final class SolvedPromise<T> extends SolvablePromise<T>
  • Constructor Details

    • SolvedPromise

      public SolvedPromise(Try<T> value)
  • Method Details

    • 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 applied 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 applied on success which can raise an error
      onError - The function to applied 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 applied 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>>