Package io.activej.promise
Class Promises
- java.lang.Object
-
- io.activej.promise.Promises
-
-
Constructor Summary
Constructors Constructor Description Promises()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NotNull Promise<Void>all()static @NotNull Promise<Void>all(@NotNull Promise<?> promise1)static @NotNull Promise<Void>all(@NotNull Promise<?>... promises)static @NotNull Promise<Void>all(@NotNull Promise<?> promise1, @NotNull Promise<?> promise2)Optimized for 2 promises.static @NotNull Promise<Void>all(@NotNull Iterator<? extends Promise<?>> promises)ReturnsPromisethat completes when all of thepromisesare completed.static @NotNull Promise<Void>all(@NotNull List<? extends Promise<?>> promises)Returns aPromisethat completes when all of thepromisesare completed.static @NotNull Promise<Void>all(@NotNull Stream<? extends Promise<?>> promises)static <T> @NotNull Promise<T>any()Returns aCompleteExceptionallyPromisewithException, since this method doesn't accept anyPromisesstatic <T> @NotNull Promise<T>any(@NotNull Promise<? extends T> promise1)static <T> @NotNull Promise<T>any(@NotNull Promise<? extends T>... promises)static <T> @NotNull Promise<T>any(@NotNull Promise<? extends T> promise1, @NotNull Promise<? extends T> promise2)Optimized for 2 promises.static <T> @NotNull Promise<T>any(@NotNull BiPredicate<T,Throwable> predicate, @NotNull Promise<? extends T> promise1)static <T> @NotNull Promise<T>any(@NotNull BiPredicate<T,Throwable> predicate, @NotNull Promise<? extends T>... promises)static <T> @NotNull Promise<T>any(@NotNull BiPredicate<T,Throwable> predicate, @NotNull Promise<? extends T> promise1, @NotNull Promise<? extends T> promise2)static <T> @NotNull Promise<T>any(@NotNull BiPredicate<T,Throwable> predicate, @NotNull Iterator<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T>any(@NotNull BiPredicate<T,Throwable> predicate, @NotNull List<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T>any(@NotNull BiPredicate<T,Throwable> predicate, @NotNull Stream<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T>any(@NotNull Iterator<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T>any(@NotNull List<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T>any(@NotNull Stream<? extends Promise<? extends T>> promises)static <T> Iterator<Promise<T>>asPromises(@NotNull AsyncSupplier<? extends T>... tasks)static <T> Iterator<Promise<T>>asPromises(@NotNull Iterable<? extends AsyncSupplier<? extends T>> tasks)static <T> @NotNull Iterator<Promise<T>>asPromises(@NotNull Iterator<? extends AsyncSupplier<? extends T>> tasks)static <T> Iterator<Promise<T>>asPromises(@NotNull Stream<? extends AsyncSupplier<? extends T>> tasks)static <T,A,R>
@NotNull Function<T,Promise<R>>coalesce(@NotNull Supplier<A> argumentAccumulatorSupplier, @NotNull BiConsumer<A,T> argumentAccumulatorFn, @NotNull Function<A,Promise<R>> fn)static @NotNull Promise<Void>delay(long delayMillis)static <T> @NotNull Promise<T>delay(long delayMillis, @NotNull Promise<T> promise)Delays completion of providedpromisefor the defined period of time.static <T> @NotNull Promise<T>delay(long delayMillis, T value)static @NotNull Promise<Void>delay(@NotNull Duration delay)static <T> @NotNull Promise<T>delay(@NotNull Duration delay, @NotNull Promise<T> promise)static <T> @NotNull Promise<T>delay(@NotNull Duration delay, T value)static <T> @NotNull Promise<T>first(@NotNull Iterable<? extends AsyncSupplier<? extends T>> promises)static <T> @NotNull Promise<T>first(@NotNull BiPredicate<? super T,? super Throwable> predicate, @NotNull AsyncSupplier<? extends T>... promises)static <T> @NotNull Promise<T>first(@NotNull BiPredicate<? super T,? super Throwable> predicate, @NotNull Iterable<? extends AsyncSupplier<? extends T>> promises)static <T> @NotNull Promise<T>first(@NotNull BiPredicate<? super T,? super Throwable> predicate, @NotNull Iterator<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T>first(@NotNull BiPredicate<? super T,? super Throwable> predicate, @NotNull Stream<? extends AsyncSupplier<? extends T>> promises)static <T> @NotNull Promise<T>first(@NotNull Iterator<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T>first(@NotNull Stream<? extends AsyncSupplier<? extends T>> promises)static <T> @NotNull Promise<T>first(AsyncSupplier<? extends T>... promises)Picks the firstPromisethat was completed without exception.static <T> @NotNull Promise<T>interval(long intervalMillis, @NotNull Promise<T> promise)static <T> @NotNull Promise<T>interval(@NotNull Duration interval, @NotNull Promise<T> promise)static <T> @NotNull BiPredicate<T,Throwable>isError()Returns aBiPredicatewhich checks ifPromisewas completed with an exception.static <T> @NotNull BiPredicate<T,Throwable>isError(Predicate<? super Throwable> predicate)static <T> @NotNull BiPredicate<T,Throwable>isResult()Returns aBiPredicatewhich checks ifPromisewasn't completed exceptionally.static <T> BiPredicate<T,Throwable>isResult(Predicate<? super T> predicate)static <T> BiPredicate<T,Throwable>isResultOrError(Predicate<? super T> predicate)static <T> BiPredicate<T,Throwable>isResultOrError(Predicate<? super T> predicate, Predicate<? super Throwable> predicateError)static <T> Promise<T>loop(T seed, @NotNull Predicate<T> loopCondition, @NotNull Function<T,Promise<T>> next)static <T,T1,R,R1>
@NotNull Function<T,Promise<R>>mapTuple(@NotNull io.activej.common.tuple.TupleConstructor1<R1,R> constructor, @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1)static <T,T1,T2,R,R1,R2>
@NotNull Function<T,Promise<R>>mapTuple(@NotNull io.activej.common.tuple.TupleConstructor2<R1,R2,R> constructor, @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2)static <T,T1,T2,T3,R,R1,R2,R3>
@NotNull Function<T,Promise<R>>mapTuple(@NotNull io.activej.common.tuple.TupleConstructor3<R1,R2,R3,R> constructor, @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2, @NotNull Function<? super T,T3> getter3, Function<T3,? extends Promise<R3>> fn3)static <T,T1,T2,T3,T4,R,R1,R2,R3,R4>
@NotNull Function<T,Promise<R>>mapTuple(@NotNull io.activej.common.tuple.TupleConstructor4<R1,R2,R3,R4,R> constructor, @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2, @NotNull Function<? super T,T3> getter3, Function<T3,? extends Promise<R3>> fn3, @NotNull Function<? super T,T4> getter4, Function<T4,? extends Promise<R4>> fn4)static <T,T1,T2,T3,T4,T5,R,R1,R2,R3,R4,R5>
@NotNull Function<T,Promise<R>>mapTuple(@NotNull io.activej.common.tuple.TupleConstructor5<R1,R2,R3,R4,R5,R> constructor, @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2, @NotNull Function<? super T,T3> getter3, Function<T3,? extends Promise<R3>> fn3, @NotNull Function<? super T,T4> getter4, Function<T4,? extends Promise<R4>> fn4, @NotNull Function<? super T,T5> getter5, Function<T5,? extends Promise<R5>> fn5)static <T,T1,T2,T3,T4,T5,T6,R,R1,R2,R3,R4,R5,R6>
@NotNull Function<T,Promise<R>>mapTuple(@NotNull io.activej.common.tuple.TupleConstructor6<R1,R2,R3,R4,R5,R6,R> constructor, @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2, @NotNull Function<? super T,T3> getter3, Function<T3,? extends Promise<R3>> fn3, @NotNull Function<? super T,T4> getter4, Function<T4,? extends Promise<R4>> fn4, @NotNull Function<? super T,T5> getter5, Function<T5,? extends Promise<R5>> fn5, @NotNull Function<? super T,T6> getter6, Function<T6,? extends Promise<R6>> fn6)static <T,A,R>
Promise<R>reduce(@NotNull Collector<T,A,R> collector, int maxCalls, @NotNull Iterator<Promise<T>> promises)static <T,A,R>
Promise<R>reduce(A accumulator, @NotNull BiConsumer<A,T> consumer, @NotNull Function<A,R> finisher, int maxCalls, @NotNull Iterator<Promise<T>> promises)static @NotNull Promise<Void>repeat(@NotNull Supplier<Promise<Boolean>> supplier)Repeats the operations of providedsupplierinfinitely, until one of thePromises completes exceptionally.static <T> Promise<T>retry(AsyncSupplier<T> asyncSupplier)static <T> Promise<T>retry(AsyncSupplier<T> asyncSupplier, @NotNull RetryPolicy<?> retryPolicy)static <T> Promise<T>retry(AsyncSupplier<T> asyncSupplier, BiPredicate<T,Throwable> breakCondition, @NotNull RetryPolicy<?> retryPolicy)static <T> Promise<T>retry(BiPredicate<T,Throwable> breakCondition, AsyncSupplier<T> asyncSupplier)static @NotNull Promise<Void>schedule(long timestamp)static <T> @NotNull Promise<T>schedule(@NotNull Promise<T> promise, long timestamp)Schedules completion of thePromiseso that it will be completed after the timestamp even if its operations were completed earlier.static <T> @NotNull Promise<T>schedule(@NotNull Promise<T> promise, @NotNull Instant instant)static @NotNull Promise<Void>schedule(@NotNull Instant instant)static <T> @NotNull Promise<T>schedule(T value, long timestamp)static <T> @NotNull Promise<T>schedule(T value, @NotNull Instant instant)static @NotNull Promise<Void>sequence()Returns aCompleteNullPromisestatic @NotNull Promise<Void>sequence(@NotNull AsyncSupplier<Void> promise)GetsPromisefrom providedAsyncSupplier, waits until it completes and than returns aPromise<Void>static @NotNull Promise<Void>sequence(@NotNull AsyncSupplier<Void>... promises)static @NotNull Promise<Void>sequence(@NotNull AsyncSupplier<Void> promise1, @NotNull AsyncSupplier<Void> promise2)GetsPromises from providedAsyncSuppliers, end executes them consequently, discarding their results.static @NotNull Promise<Void>sequence(@NotNull Iterable<? extends AsyncSupplier<Void>> promises)static @NotNull Promise<Void>sequence(@NotNull Iterator<? extends Promise<Void>> promises)Calls everyPromisefrompromisesin sequence and discards their results.Returns aSettablePromisewithnullresult as a marker when all of thepromisesare completed.static @NotNull Promise<Void>sequence(@NotNull Stream<? extends AsyncSupplier<Void>> promises)static <T> @NotNull Promise<T>timeout(long delay, @NotNull Promise<T> promise)Waits until the delay passes and if thePromiseis still not complete, tries to complete it withTIMEOUT_EXCEPTION.static <T> @NotNull Promise<T>timeout(@NotNull Duration delay, @NotNull Promise<T> promise)static <T> @NotNull Promise<T[]>toArray(@NotNull Class<T> type)Returns an array of providedtypeand length 0 wrapped inPromise.static <T> @NotNull Promise<T[]>toArray(@NotNull Class<T> type, @NotNull Promise<? extends T> promise1)Returns an array withpromise1result.static <T> @NotNull Promise<T[]>toArray(@NotNull Class<T> type, @NotNull Promise<? extends T>... promises)static <T> @NotNull Promise<T[]>toArray(@NotNull Class<T> type, @NotNull Promise<? extends T> promise1, @NotNull Promise<? extends T> promise2)Returns an array withpromise1andpromise2results.static <T> @NotNull Promise<T[]>toArray(@NotNull Class<T> type, @NotNull Iterable<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T[]>toArray(@NotNull Class<T> type, @NotNull Iterator<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<T[]>toArray(@NotNull Class<T> type, @NotNull List<? extends Promise<? extends T>> promises)Reduces promises into Promise<Array>static <T> @NotNull Promise<T[]>toArray(@NotNull Class<T> type, @NotNull Stream<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<List<T>>toList()Returns a successfully completedPromisewith an empty list as the result.static <T> @NotNull Promise<List<T>>toList(@NotNull Promise<? extends T> promise1)Returns a completedPromisewith a result wrapped inList.static <T> @NotNull Promise<List<T>>toList(@NotNull Promise<? extends T>... promises)static <T> @NotNull Promise<List<T>>toList(@NotNull Promise<? extends T> promise1, @NotNull Promise<? extends T> promise2)ReturnsPromisewith a list ofpromise1andpromise2results.static <T> @NotNull Promise<List<T>>toList(@NotNull Iterable<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<List<T>>toList(@NotNull Iterator<? extends Promise<? extends T>> promises)static <T> @NotNull Promise<List<T>>toList(@NotNull List<? extends Promise<? extends T>> promises)Reduces list ofPromises into Promise<List>.static <T> @NotNull Promise<List<T>>toList(@NotNull Stream<? extends Promise<? extends T>> promises)static <T1,R>
@NotNull Promise<R>toTuple(@NotNull io.activej.common.tuple.TupleConstructor1<T1,R> constructor, @NotNull Promise<? extends T1> promise1)static <T1,T2,R>
@NotNull Promise<R>toTuple(@NotNull io.activej.common.tuple.TupleConstructor2<T1,T2,R> constructor, @NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2)static <T1,T2,T3,R>
@NotNull Promise<R>toTuple(@NotNull io.activej.common.tuple.TupleConstructor3<T1,T2,T3,R> constructor, @NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2, @NotNull Promise<? extends T3> promise3)static <T1,T2,T3,T4,R>
@NotNull Promise<R>toTuple(@NotNull io.activej.common.tuple.TupleConstructor4<T1,T2,T3,T4,R> constructor, @NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2, @NotNull Promise<? extends T3> promise3, @NotNull Promise<? extends T4> promise4)static <T1,T2,T3,T4,T5,R>
@NotNull Promise<R>toTuple(@NotNull io.activej.common.tuple.TupleConstructor5<T1,T2,T3,T4,T5,R> constructor, @NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2, @NotNull Promise<? extends T3> promise3, @NotNull Promise<? extends T4> promise4, @NotNull Promise<? extends T5> promise5)static <T1,T2,T3,T4,T5,T6,R>
@NotNull Promise<R>toTuple(@NotNull io.activej.common.tuple.TupleConstructor6<T1,T2,T3,T4,T5,T6,R> constructor, @NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2, @NotNull Promise<? extends T3> promise3, @NotNull Promise<? extends T4> promise4, @NotNull Promise<? extends T5> promise5, @NotNull Promise<? extends T6> promise6)static <T1> @NotNull Promise<io.activej.common.tuple.Tuple1<T1>>toTuple(@NotNull Promise<? extends T1> promise1)static <T1,T2>
@NotNull Promise<io.activej.common.tuple.Tuple2<T1,T2>>toTuple(@NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2)static <T1,T2,T3>
@NotNull Promise<io.activej.common.tuple.Tuple3<T1,T2,T3>>toTuple(@NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2, @NotNull Promise<? extends T3> promise3)static <T1,T2,T3,T4>
@NotNull Promise<io.activej.common.tuple.Tuple4<T1,T2,T3,T4>>toTuple(@NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2, @NotNull Promise<? extends T3> promise3, @NotNull Promise<? extends T4> promise4)static <T1,T2,T3,T4,T5>
@NotNull Promise<io.activej.common.tuple.Tuple5<T1,T2,T3,T4,T5>>toTuple(@NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2, @NotNull Promise<? extends T3> promise3, @NotNull Promise<? extends T4> promise4, @NotNull Promise<? extends T5> promise5)static <T1,T2,T3,T4,T5,T6>
@NotNull Promise<io.activej.common.tuple.Tuple6<T1,T2,T3,T4,T5,T6>>toTuple(@NotNull Promise<? extends T1> promise1, @NotNull Promise<? extends T2> promise2, @NotNull Promise<? extends T3> promise3, @NotNull Promise<? extends T4> promise4, @NotNull Promise<? extends T5> promise5, @NotNull Promise<? extends T6> promise6)static <T> Promise<T>until(T seed, @NotNull Function<T,Promise<T>> next, @NotNull Predicate<T> breakCondition)
-
-
-
Method Detail
-
timeout
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> timeout(@NotNull @NotNull Duration delay, @NotNull @NotNull Promise<T> promise)
- See Also:
timeout(long, Promise)
-
timeout
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> timeout(long delay, @NotNull @NotNull Promise<T> promise)
Waits until the delay passes and if thePromiseis still not complete, tries to complete it withTIMEOUT_EXCEPTION.- Parameters:
delay- time of delaypromise- the Promise to be tracked- Returns:
Promise
-
delay
@Contract(pure=true) @NotNull public static @NotNull Promise<Void> delay(@NotNull @NotNull Duration delay)
-
delay
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> delay(@NotNull @NotNull Duration delay, T value)
-
delay
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> delay(long delayMillis, T value)
-
delay
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> delay(@NotNull @NotNull Duration delay, @NotNull @NotNull Promise<T> promise)
- See Also:
delay(long, Promise)
-
delay
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> delay(long delayMillis, @NotNull @NotNull Promise<T> promise)
Delays completion of providedpromisefor the defined period of time.- Parameters:
delayMillis- delay in millispromise- thePromiseto be delayed- Returns:
- completed
Promise
-
interval
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> interval(@NotNull @NotNull Duration interval, @NotNull @NotNull Promise<T> promise)
-
interval
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> interval(long intervalMillis, @NotNull @NotNull Promise<T> promise)
-
schedule
@Contract(pure=true) @NotNull public static @NotNull Promise<Void> schedule(@NotNull @NotNull Instant instant)
- See Also:
schedule(Promise, long)
-
schedule
@Contract(pure=true) @NotNull public static @NotNull Promise<Void> schedule(long timestamp)
- See Also:
schedule(Promise, long)
-
schedule
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> schedule(T value, @NotNull @NotNull Instant instant)
- See Also:
schedule(Promise, long)
-
schedule
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> schedule(T value, long timestamp)
- See Also:
schedule(Promise, long)
-
schedule
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> schedule(@NotNull @NotNull Promise<T> promise, @NotNull @NotNull Instant instant)
- See Also:
schedule(Promise, long)
-
schedule
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> schedule(@NotNull @NotNull Promise<T> promise, long timestamp)
Schedules completion of thePromiseso that it will be completed after the timestamp even if its operations were completed earlier.
-
all
@Contract(pure=true) @NotNull public static @NotNull Promise<Void> all(@NotNull @NotNull Promise<?> promise1)
- See Also:
all(List)
-
all
@Contract(pure=true) @NotNull public static @NotNull Promise<Void> all(@NotNull @NotNull Promise<?> promise1, @NotNull @NotNull Promise<?> promise2)
Optimized for 2 promises.- See Also:
all(List)
-
all
@Contract(pure=true) @NotNull public static @NotNull Promise<Void> all(@NotNull @NotNull Promise<?>... promises)
- See Also:
all(List)
-
all
@Contract(pure=true) @NotNull public static @NotNull Promise<Void> all(@NotNull @NotNull List<? extends Promise<?>> promises)
Returns aPromisethat completes when all of thepromisesare completed.
-
all
@Contract(pure=true) @NotNull public static @NotNull Promise<Void> all(@NotNull @NotNull Stream<? extends Promise<?>> promises)
- See Also:
all(List)
-
all
@NotNull public static @NotNull Promise<Void> all(@NotNull @NotNull Iterator<? extends Promise<?>> promises)
ReturnsPromisethat completes when all of thepromisesare completed. If at least one of thepromisescompletes exceptionally, aCompleteExceptionallyPromisewill be returned.
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any()
Returns aCompleteExceptionallyPromisewithException, since this method doesn't accept anyPromises- See Also:
any(Iterator)
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull Promise<? extends T> promise1)
- See Also:
any(Iterator)
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull Promise<? extends T> promise1, @NotNull @NotNull Promise<? extends T> promise2)
Optimized for 2 promises.- See Also:
any(Iterator)
-
any
@Contract(pure=true) @NotNull @SafeVarargs public static <T> @NotNull Promise<T> any(@NotNull @NotNull Promise<? extends T>... promises)
- See Also:
any(Iterator)
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull List<? extends Promise<? extends T>> promises)
- See Also:
any(Iterator)
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull Stream<? extends Promise<? extends T>> promises)
- See Also:
any(Iterator)
-
any
@NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull Iterator<? extends Promise<? extends T>> promises)
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull BiPredicate<T,Throwable> predicate, @NotNull @NotNull Promise<? extends T> promise1)
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull BiPredicate<T,Throwable> predicate, @NotNull @NotNull Promise<? extends T> promise1, @NotNull @NotNull Promise<? extends T> promise2)
-
any
@Contract(pure=true) @NotNull @SafeVarargs public static <T> @NotNull Promise<T> any(@NotNull @NotNull BiPredicate<T,Throwable> predicate, @NotNull @NotNull Promise<? extends T>... promises)
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull BiPredicate<T,Throwable> predicate, @NotNull @NotNull Stream<? extends Promise<? extends T>> promises)
-
any
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull BiPredicate<T,Throwable> predicate, @NotNull @NotNull List<? extends Promise<? extends T>> promises)
-
any
@NotNull public static <T> @NotNull Promise<T> any(@NotNull @NotNull BiPredicate<T,Throwable> predicate, @NotNull @NotNull Iterator<? extends Promise<? extends T>> promises)
-
toList
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<List<T>> toList()
Returns a successfully completedPromisewith an empty list as the result.
-
toList
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<List<T>> toList(@NotNull @NotNull Promise<? extends T> promise1)
Returns a completedPromisewith a result wrapped inList.
-
toList
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<List<T>> toList(@NotNull @NotNull Promise<? extends T> promise1, @NotNull @NotNull Promise<? extends T> promise2)
ReturnsPromisewith a list ofpromise1andpromise2results.
-
toList
@Contract(pure=true) @NotNull @SafeVarargs public static <T> @NotNull Promise<List<T>> toList(@NotNull @NotNull Promise<? extends T>... promises)
- See Also:
toList(List)
-
toList
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<List<T>> toList(@NotNull @NotNull List<? extends Promise<? extends T>> promises)
Reduces list ofPromises into Promise<List>.
-
toList
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<List<T>> toList(@NotNull @NotNull Stream<? extends Promise<? extends T>> promises)
- See Also:
toList(List)
-
toList
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<List<T>> toList(@NotNull @NotNull Iterable<? extends Promise<? extends T>> promises)
- See Also:
toList(List)
-
toList
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<List<T>> toList(@NotNull @NotNull Iterator<? extends Promise<? extends T>> promises)
- See Also:
toList(List)
-
toArray
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T[]> toArray(@NotNull @NotNull Class<T> type)
Returns an array of providedtypeand length 0 wrapped inPromise.
-
toArray
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T[]> toArray(@NotNull @NotNull Class<T> type, @NotNull @NotNull Promise<? extends T> promise1)
Returns an array withpromise1result.
-
toArray
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T[]> toArray(@NotNull @NotNull Class<T> type, @NotNull @NotNull Promise<? extends T> promise1, @NotNull @NotNull Promise<? extends T> promise2)
Returns an array withpromise1andpromise2results.
-
toArray
@Contract(pure=true) @NotNull @SafeVarargs public static <T> @NotNull Promise<T[]> toArray(@NotNull @NotNull Class<T> type, @NotNull @NotNull Promise<? extends T>... promises)
- See Also:
toArray(Class, List)
-
toArray
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T[]> toArray(@NotNull @NotNull Class<T> type, @NotNull @NotNull List<? extends Promise<? extends T>> promises)
Reduces promises into Promise<Array>
-
toArray
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T[]> toArray(@NotNull @NotNull Class<T> type, @NotNull @NotNull Stream<? extends Promise<? extends T>> promises)
- See Also:
toArray(Class, List)
-
toArray
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T[]> toArray(@NotNull @NotNull Class<T> type, @NotNull @NotNull Iterable<? extends Promise<? extends T>> promises)
- See Also:
toArray(Class, List)
-
toArray
@Contract(pure=true) @NotNull public static <T> @NotNull Promise<T[]> toArray(@NotNull @NotNull Class<T> type, @NotNull @NotNull Iterator<? extends Promise<? extends T>> promises)
- See Also:
toArray(Class, List)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,R> @NotNull Promise<R> toTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor1<T1,R> constructor, @NotNull @NotNull Promise<? extends T1> promise1)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,R> @NotNull Promise<R> toTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor2<T1,T2,R> constructor, @NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,T3,R> @NotNull Promise<R> toTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor3<T1,T2,T3,R> constructor, @NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2, @NotNull @NotNull Promise<? extends T3> promise3)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,T3,T4,R> @NotNull Promise<R> toTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor4<T1,T2,T3,T4,R> constructor, @NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2, @NotNull @NotNull Promise<? extends T3> promise3, @NotNull @NotNull Promise<? extends T4> promise4)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,T3,T4,T5,R> @NotNull Promise<R> toTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor5<T1,T2,T3,T4,T5,R> constructor, @NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2, @NotNull @NotNull Promise<? extends T3> promise3, @NotNull @NotNull Promise<? extends T4> promise4, @NotNull @NotNull Promise<? extends T5> promise5)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,T3,T4,T5,T6,R> @NotNull Promise<R> toTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor6<T1,T2,T3,T4,T5,T6,R> constructor, @NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2, @NotNull @NotNull Promise<? extends T3> promise3, @NotNull @NotNull Promise<? extends T4> promise4, @NotNull @NotNull Promise<? extends T5> promise5, @NotNull @NotNull Promise<? extends T6> promise6)
-
toTuple
@Contract(pure=true) @NotNull public static <T1> @NotNull Promise<io.activej.common.tuple.Tuple1<T1>> toTuple(@NotNull @NotNull Promise<? extends T1> promise1)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2> @NotNull Promise<io.activej.common.tuple.Tuple2<T1,T2>> toTuple(@NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,T3> @NotNull Promise<io.activej.common.tuple.Tuple3<T1,T2,T3>> toTuple(@NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2, @NotNull @NotNull Promise<? extends T3> promise3)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,T3,T4> @NotNull Promise<io.activej.common.tuple.Tuple4<T1,T2,T3,T4>> toTuple(@NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2, @NotNull @NotNull Promise<? extends T3> promise3, @NotNull @NotNull Promise<? extends T4> promise4)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,T3,T4,T5> @NotNull Promise<io.activej.common.tuple.Tuple5<T1,T2,T3,T4,T5>> toTuple(@NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2, @NotNull @NotNull Promise<? extends T3> promise3, @NotNull @NotNull Promise<? extends T4> promise4, @NotNull @NotNull Promise<? extends T5> promise5)
-
toTuple
@Contract(pure=true) @NotNull public static <T1,T2,T3,T4,T5,T6> @NotNull Promise<io.activej.common.tuple.Tuple6<T1,T2,T3,T4,T5,T6>> toTuple(@NotNull @NotNull Promise<? extends T1> promise1, @NotNull @NotNull Promise<? extends T2> promise2, @NotNull @NotNull Promise<? extends T3> promise3, @NotNull @NotNull Promise<? extends T4> promise4, @NotNull @NotNull Promise<? extends T5> promise5, @NotNull @NotNull Promise<? extends T6> promise6)
-
mapTuple
@Contract(pure=true) @NotNull public static <T,T1,R,R1> @NotNull Function<T,Promise<R>> mapTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor1<R1,R> constructor, @NotNull @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1)
-
mapTuple
@Contract(pure=true) @NotNull public static <T,T1,T2,R,R1,R2> @NotNull Function<T,Promise<R>> mapTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor2<R1,R2,R> constructor, @NotNull @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2)
-
mapTuple
@Contract(pure=true) @NotNull public static <T,T1,T2,T3,R,R1,R2,R3> @NotNull Function<T,Promise<R>> mapTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor3<R1,R2,R3,R> constructor, @NotNull @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2, @NotNull @NotNull Function<? super T,T3> getter3, Function<T3,? extends Promise<R3>> fn3)
-
mapTuple
@Contract(pure=true) @NotNull public static <T,T1,T2,T3,T4,R,R1,R2,R3,R4> @NotNull Function<T,Promise<R>> mapTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor4<R1,R2,R3,R4,R> constructor, @NotNull @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2, @NotNull @NotNull Function<? super T,T3> getter3, Function<T3,? extends Promise<R3>> fn3, @NotNull @NotNull Function<? super T,T4> getter4, Function<T4,? extends Promise<R4>> fn4)
-
mapTuple
@Contract(pure=true) @NotNull public static <T,T1,T2,T3,T4,T5,R,R1,R2,R3,R4,R5> @NotNull Function<T,Promise<R>> mapTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor5<R1,R2,R3,R4,R5,R> constructor, @NotNull @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2, @NotNull @NotNull Function<? super T,T3> getter3, Function<T3,? extends Promise<R3>> fn3, @NotNull @NotNull Function<? super T,T4> getter4, Function<T4,? extends Promise<R4>> fn4, @NotNull @NotNull Function<? super T,T5> getter5, Function<T5,? extends Promise<R5>> fn5)
-
mapTuple
@Contract(pure=true) @NotNull public static <T,T1,T2,T3,T4,T5,T6,R,R1,R2,R3,R4,R5,R6> @NotNull Function<T,Promise<R>> mapTuple(@NotNull @NotNull io.activej.common.tuple.TupleConstructor6<R1,R2,R3,R4,R5,R6,R> constructor, @NotNull @NotNull Function<? super T,T1> getter1, Function<T1,? extends Promise<R1>> fn1, @NotNull @NotNull Function<? super T,T2> getter2, Function<T2,? extends Promise<R2>> fn2, @NotNull @NotNull Function<? super T,T3> getter3, Function<T3,? extends Promise<R3>> fn3, @NotNull @NotNull Function<? super T,T4> getter4, Function<T4,? extends Promise<R4>> fn4, @NotNull @NotNull Function<? super T,T5> getter5, Function<T5,? extends Promise<R5>> fn5, @NotNull @NotNull Function<? super T,T6> getter6, Function<T6,? extends Promise<R6>> fn6)
-
sequence
@NotNull public static @NotNull Promise<Void> sequence()
Returns aCompleteNullPromise
-
sequence
@NotNull public static @NotNull Promise<Void> sequence(@NotNull @NotNull AsyncSupplier<Void> promise)
GetsPromisefrom providedAsyncSupplier, waits until it completes and than returns aPromise<Void>
-
sequence
@NotNull public static @NotNull Promise<Void> sequence(@NotNull @NotNull AsyncSupplier<Void> promise1, @NotNull @NotNull AsyncSupplier<Void> promise2)
GetsPromises from providedAsyncSuppliers, end executes them consequently, discarding their results.
-
sequence
@NotNull @SafeVarargs public static @NotNull Promise<Void> sequence(@NotNull @NotNull AsyncSupplier<Void>... promises)
- See Also:
sequence(Iterator)
-
sequence
@NotNull public static @NotNull Promise<Void> sequence(@NotNull @NotNull Iterable<? extends AsyncSupplier<Void>> promises)
- See Also:
sequence(Iterator)
-
sequence
@NotNull public static @NotNull Promise<Void> sequence(@NotNull @NotNull Stream<? extends AsyncSupplier<Void>> promises)
- See Also:
sequence(Iterator)
-
sequence
@NotNull public static @NotNull Promise<Void> sequence(@NotNull @NotNull Iterator<? extends Promise<Void>> promises)
Calls everyPromisefrompromisesin sequence and discards their results.Returns aSettablePromisewithnullresult as a marker when all of thepromisesare completed.- Returns:
Promisethat completes when allpromisesare completed
-
first
@NotNull @SafeVarargs public static <T> @NotNull Promise<T> first(AsyncSupplier<? extends T>... promises)
Picks the firstPromisethat was completed without exception.- See Also:
first(BiPredicate, Iterator)
-
first
@NotNull public static <T> @NotNull Promise<T> first(@NotNull @NotNull Iterable<? extends AsyncSupplier<? extends T>> promises)
-
first
@NotNull public static <T> @NotNull Promise<T> first(@NotNull @NotNull Stream<? extends AsyncSupplier<? extends T>> promises)
-
first
@NotNull public static <T> @NotNull Promise<T> first(@NotNull @NotNull Iterator<? extends Promise<? extends T>> promises)
-
first
@NotNull @SafeVarargs public static <T> @NotNull Promise<T> first(@NotNull @NotNull BiPredicate<? super T,? super Throwable> predicate, @NotNull @NotNull AsyncSupplier<? extends T>... promises)
- See Also:
first(BiPredicate, Iterator)
-
first
@NotNull public static <T> @NotNull Promise<T> first(@NotNull @NotNull BiPredicate<? super T,? super Throwable> predicate, @NotNull @NotNull Iterable<? extends AsyncSupplier<? extends T>> promises)
- See Also:
first(BiPredicate, Iterator)
-
first
@NotNull public static <T> @NotNull Promise<T> first(@NotNull @NotNull BiPredicate<? super T,? super Throwable> predicate, @NotNull @NotNull Stream<? extends AsyncSupplier<? extends T>> promises)
- See Also:
first(BiPredicate, Iterator)
-
first
@NotNull public static <T> @NotNull Promise<T> first(@NotNull @NotNull BiPredicate<? super T,? super Throwable> predicate, @NotNull @NotNull Iterator<? extends Promise<? extends T>> promises)
- Parameters:
predicate- filters results, consumes result ofPromise- Returns:
- first completed result of
Promisethat satisfies predicate
-
isResult
@NotNull public static <T> @NotNull BiPredicate<T,Throwable> isResult()
Returns aBiPredicatewhich checks ifPromisewasn't completed exceptionally.
-
isResult
public static <T> BiPredicate<T,Throwable> isResult(Predicate<? super T> predicate)
-
isResultOrError
public static <T> BiPredicate<T,Throwable> isResultOrError(Predicate<? super T> predicate)
-
isResultOrError
public static <T> BiPredicate<T,Throwable> isResultOrError(Predicate<? super T> predicate, Predicate<? super Throwable> predicateError)
-
isError
@NotNull public static <T> @NotNull BiPredicate<T,Throwable> isError()
Returns aBiPredicatewhich checks ifPromisewas completed with an exception.
-
isError
@NotNull public static <T> @NotNull BiPredicate<T,Throwable> isError(Predicate<? super Throwable> predicate)
-
repeat
@NotNull public static @NotNull Promise<Void> repeat(@NotNull @NotNull Supplier<Promise<Boolean>> supplier)
Repeats the operations of providedsupplierinfinitely, until one of thePromises completes exceptionally.
-
loop
public static <T> Promise<T> loop(@Nullable T seed, @NotNull @NotNull Predicate<T> loopCondition, @NotNull @NotNull Function<T,Promise<T>> next)
Repeats providedFunctionuntil can passPredicatetest. Resembles a simple Javafor()loop but with async capabilities.- Parameters:
seed- start valueloopCondition- a boolean function which checks if this loop can continuenext- a function applied to the seed, returnsPromise- Returns:
SettablePromisewithnullresult if it was completed successfully, otherwise returns aSettablePromisewith an exception. In both situations returnedPromiseis a marker of completion of the loop.
-
until
public static <T> Promise<T> until(@Nullable T seed, @NotNull @NotNull Function<T,Promise<T>> next, @NotNull @NotNull Predicate<T> breakCondition)
-
retry
public static <T> Promise<T> retry(AsyncSupplier<T> asyncSupplier)
-
retry
public static <T> Promise<T> retry(BiPredicate<T,Throwable> breakCondition, AsyncSupplier<T> asyncSupplier)
-
retry
public static <T> Promise<T> retry(AsyncSupplier<T> asyncSupplier, @NotNull @NotNull RetryPolicy<?> retryPolicy)
-
retry
public static <T> Promise<T> retry(AsyncSupplier<T> asyncSupplier, BiPredicate<T,Throwable> breakCondition, @NotNull @NotNull RetryPolicy<?> retryPolicy)
-
asPromises
@NotNull public static <T> @NotNull Iterator<Promise<T>> asPromises(@NotNull @NotNull Iterator<? extends AsyncSupplier<? extends T>> tasks)
-
asPromises
public static <T> Iterator<Promise<T>> asPromises(@NotNull @NotNull Stream<? extends AsyncSupplier<? extends T>> tasks)
-
asPromises
public static <T> Iterator<Promise<T>> asPromises(@NotNull @NotNull Iterable<? extends AsyncSupplier<? extends T>> tasks)
-
asPromises
@SafeVarargs public static <T> Iterator<Promise<T>> asPromises(@NotNull @NotNull AsyncSupplier<? extends T>... tasks)
-
reduce
public static <T,A,R> Promise<R> reduce(@NotNull @NotNull Collector<T,A,R> collector, int maxCalls, @NotNull @NotNull Iterator<Promise<T>> promises)
Allows to asynchronously reduceIteratorofPromises into aPromisewith the help ofCollector. You can control the amount of concurrently runningPromise.This method is universal and allows to implement app-specific logic.
- Type Parameters:
T- type of input elements for this operationA- mutable accumulation type of the operationR- the result type of the operation- Parameters:
collector- mutable reduction operation that accumulates input elements into a mutable result containermaxCalls- max amount of concurrently runningPromisespromises-IterableofPromises- Returns:
- a
Promisewhich wraps the accumulated result of the reduction. If one of thepromisescompleted exceptionally, aPromisewith an exception will be returned.
-
reduce
public static <T,A,R> Promise<R> reduce(A accumulator, @NotNull @NotNull BiConsumer<A,T> consumer, @NotNull @NotNull Function<A,R> finisher, int maxCalls, @NotNull @NotNull Iterator<Promise<T>> promises)
- Type Parameters:
T- type of input elements for this operationA- mutable accumulation type of the operationR- result type of the reduction operation- Parameters:
accumulator- supplier of the resultconsumer- aBiConsumerwhich folds a result of each of the completedpromisesinto accumulatorfinisher- aFunctionwhich performs the final transformation from the intermediate accumulationsmaxCalls- max amount of concurrently runningPromisespromises-IterableofPromises- Returns:
- a
Promisewhich wraps the accumulated result of the reduction. If one of thepromisescompleted exceptionally, aPromisewith an exception will be returned. - See Also:
reduce(Collector, int, Iterator)
-
-