Class Promises.Results

java.lang.Object
org.forgerock.util.promise.Promises.Results
Enclosing class:
Promises

public static class Promises.Results extends Object
Ordered list of joined asynchronous results.

Order of the results is guaranteed to be the same as the order of joined promises, so that results can be accessed safely using their index with get(int).

     
     Promise<String, IOException> p1 = ...
     Promise<Integer, Exception> p2 = ...
     Promises.join(Arrays.asList(p1, p2))
             .then(results -> {
               String text = results.get(0);
               int times = results.get(1);
               return text + "" + times;
             })
     
 
See Also:
  • Method Details

    • get

      public <T> T get(int i)
      Returns the result stored at the index i.

      Note that an un-checked cast is done.

      Type Parameters:
      T - type of the result
      Parameters:
      i - index of the result
      Returns:
      the result stored at the index i.
      Throws:
      ArrayIndexOutOfBoundsException - when index i does not represent a result, i.e. no promise was submitted at this index.