Package org.hibernate.reactive.util.impl
Class CompletionStages
java.lang.Object
org.hibernate.reactive.util.impl.CompletionStages
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMakes the code simpler when dealing with ORM visitor pattern.static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CompletionStage<Void>applyToAll(Function<Object, CompletionStage<?>> op, Object[] entity) static <T> CompletionStage<T>completedFuture(T value) static <T> CompletionStage<T>static CompletionStage<Boolean>static <R,T extends Throwable>
CompletionStages.CompletionStageHandler<R,T> handle(R result, T throwable) static voidlogSqlException(Throwable t, Supplier<String> message, String sql) static CompletionStage<Void>loop(int start, int end, IntFunction<CompletionStage<?>> consumer) Equivalent to:static CompletionStage<Void>loop(int start, int end, IntPredicate filter, IntFunction<CompletionStage<?>> consumer) Equivalent to:static <T> CompletionStage<Void>loop(Collection<T> collection, Function<T, CompletionStage<?>> consumer) Equivalent to:static <T> CompletionStage<Void>loop(Collection<T> collection, Predicate<T> filter, Function<T, CompletionStage<?>> consumer) Deprecated.always prefer the variants which use a List rather than a Collectionstatic <T> CompletionStage<Void>loop(Iterator<T> iterator, IntBiFunction<T, CompletionStage<?>> consumer) Equivalent to:static <T> CompletionStage<Void>loop(Iterator<T> iterator, IntBiPredicate<T> filter, IntBiFunction<T, CompletionStage<?>> consumer) Equivalent to:static <T> CompletionStage<Void>loop(List<T> list, Function<T, CompletionStage<?>> consumer) static <T> CompletionStage<Void>loop(List<T> list, Predicate<T> filter, Function<T, CompletionStage<?>> consumer) static <T> CompletionStage<Void>loop(Queue<T> queue, Function<T, CompletionStage<?>> consumer) static <T> CompletionStage<Void>loop(T[] array, Function<T, CompletionStage<?>> consumer) Equivalent to:static <T> CompletionStage<Void>loop(T[] array, IntPredicate filter, IntFunction<CompletionStage<?>> consumer) Equivalent to:static <T> CompletionStage<T>static <T> CompletionStage<T>nullFuture(Void v) static <T extends Throwable,Ret>
Retstatic <T extends Throwable,Ret>
Retstatic <T extends Throwable,Ret>
RetreturnOrRethrow(Throwable x, Ret result) static <T> CompletionStage<T>supplyStage(Supplier<CompletionStage<T>> supplier) Useful for implementing try-finally blocks.static CompletionStage<Integer>total(int start, int end, IntFunction<CompletionStage<Integer>> consumer) Equivalent to:static <T> CompletionStage<Integer>total(Iterator<T> iterator, Function<T, CompletionStage<Integer>> consumer) Equivalent to:static <T> CompletionStage<Integer>total(T[] array, Function<T, CompletionStage<Integer>> consumer) Equivalent to:static CompletionStage<Boolean>static CompletionStage<Void>static CompletionStage<Void>voidFuture(Object ignore) static CompletionStage<Void>whileLoop(int start, int end, IntPredicate filter, IntFunction<CompletionStage<Boolean>> consumer) static CompletionStage<Void>whileLoop(Supplier<Boolean> whileCondition, Supplier<CompletionStage<?>> loopSupplier) static CompletionStage<Void>whileLoop(Supplier<CompletionStage<Boolean>> loopSupplier) static <T> CompletionStage<Void>whileLoop(T[] array, Function<T, CompletionStage<Boolean>> consumer) static CompletionStage<Integer>static CompletionStage<Integer>zeroFuture(Object ignore)
-
Constructor Details
-
CompletionStages
public CompletionStages()
-
-
Method Details
-
voidFuture
-
voidFuture
-
zeroFuture
-
zeroFuture
-
trueFuture
-
falseFuture
-
nullFuture
-
nullFuture
-
completedFuture
-
supplyStage
Useful for implementing try-finally blocks. For example:return supplyStage( () -> { // Any error here will get caught ... }) .whenComplete( (r,t) -> { // finally block ... }) -
failedFuture
-
rethrow
- Throws:
T extends Throwable
-
returnNullorRethrow
- Throws:
T extends Throwable
-
returnOrRethrow
- Throws:
T extends Throwable
-
logSqlException
-
total
public static CompletionStage<Integer> total(int start, int end, IntFunction<CompletionStage<Integer>> consumer) Equivalent to:int total = 0; for ( int i = start; i < end; i++ ) { total = total + consumer.apply( i ); } -
total
public static <T> CompletionStage<Integer> total(Iterator<T> iterator, Function<T, CompletionStage<Integer>> consumer) Equivalent to:int total = 0; while( iterator.hasNext() ) { total += consumer.apply( iterator.next() ); } -
total
public static <T> CompletionStage<Integer> total(T[] array, Function<T, CompletionStage<Integer>> consumer) Equivalent to:int total = 0; for ( int i = start; i < end; i++ ) { total = total + consumer.apply( array[i] ); } -
loop
Equivalent to:for ( int i = start; i < end; i++ ) { consumer.apply( array[i] ); } -
loop
public static <T> CompletionStage<Void> loop(T[] array, IntPredicate filter, IntFunction<CompletionStage<?>> consumer) Equivalent to:for ( int i = start; i < end; i++ ) { if ( filter.test(i) ) { consumer.apply( i ); } } -
loop
public static <T> CompletionStage<Void> loop(Iterator<T> iterator, IntBiFunction<T, CompletionStage<?>> consumer) Equivalent to:int index = 0 while( iterator.hasNext() ) { consumer.apply( iterator.next(), index++ ); } -
loop
public static <T> CompletionStage<Void> loop(Iterator<T> iterator, IntBiPredicate<T> filter, IntBiFunction<T, CompletionStage<?>> consumer) Equivalent to:int index = -1 while( iterator.hasNext() ) { index++ T next = iterator.next(); if (filter.test( next, index ) { consumer.apply( next, index ); } } -
handle
public static <R,T extends Throwable> CompletionStages.CompletionStageHandler<R,T> handle(R result, T throwable) -
loop
public static <T> CompletionStage<Void> loop(Collection<T> collection, Function<T, CompletionStage<?>> consumer) Equivalent to:for ( Object next : iterable ) { consumer.apply( next ); } -
loop
@Deprecated public static <T> CompletionStage<Void> loop(Collection<T> collection, Predicate<T> filter, Function<T, CompletionStage<?>> consumer) Deprecated.always prefer the variants which use a List rather than a Collection -
loop
-
loop
public static <T> CompletionStage<Void> loop(List<T> list, Predicate<T> filter, Function<T, CompletionStage<?>> consumer) -
loop
public static <T> CompletionStage<Void> loop(Queue<T> queue, Function<T, CompletionStage<?>> consumer) -
loop
public static CompletionStage<Void> loop(int start, int end, IntFunction<CompletionStage<?>> consumer) Equivalent to:for ( int i = start; i < end; i++ ) { consumer.apply( i ); } -
whileLoop
public static <T> CompletionStage<Void> whileLoop(T[] array, Function<T, CompletionStage<Boolean>> consumer) -
whileLoop
public static CompletionStage<Void> whileLoop(int start, int end, IntPredicate filter, IntFunction<CompletionStage<Boolean>> consumer) -
loop
public static CompletionStage<Void> loop(int start, int end, IntPredicate filter, IntFunction<CompletionStage<?>> consumer) Equivalent to:for ( int i = start; i < end; i++ ) { if ( filter.test(i) ) { consumer.apply( i ); } } -
whileLoop
-
whileLoop
public static CompletionStage<Void> whileLoop(Supplier<Boolean> whileCondition, Supplier<CompletionStage<?>> loopSupplier) -
applyToAll
public static CompletionStage<Void> applyToAll(Function<Object, CompletionStage<?>> op, Object[] entity)
-