Package org.jgroups.util
Enum CompletableFutures
- java.lang.Object
-
- java.lang.Enum<CompletableFutures>
-
- org.jgroups.util.CompletableFutures
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<CompletableFutures>
public enum CompletableFutures extends java.lang.Enum<CompletableFutures>
Utility class withCompletableFutureandCompletionStageuseful methods.- Since:
- 5.2
- Author:
- Pedro Ruivo
-
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.CompletableFuture<java.lang.Boolean>completedFalse()static <T> java.util.concurrent.CompletableFuture<T>completedNull()AnullcompletedCompletableFuture.static java.util.concurrent.CompletableFuture<java.lang.Boolean>completedTrue()static <T> Tjoin(java.util.concurrent.CompletableFuture<T> cf)Waits for theCompletableFutureto complete.static <T> Tjoin(java.util.concurrent.CompletionStage<T> cs)Same asjoin(CompletableFuture)but it receives aCompletionStageas parameter.static <T> java.util.function.Function<T,java.lang.Void>toVoidFunction()static CompletableFuturesvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static CompletableFutures[]values()Returns an array containing the constants of this enum type, in the order they are declared.static <T> java.util.function.Consumer<T>voidConsumer()Consumes any value and return aVoid.static java.util.concurrent.CompletionExceptionwrapAsCompletionException(java.lang.Throwable throwable)Wraps thethrowableintoCompletionException.
-
-
-
Enum Constant Detail
-
INSTANCE
public static final CompletableFutures INSTANCE
-
-
Method Detail
-
values
public static CompletableFutures[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (CompletableFutures c : CompletableFutures.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CompletableFutures valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
join
public static <T> T join(java.util.concurrent.CompletionStage<T> cs)
Same asjoin(CompletableFuture)but it receives aCompletionStageas parameter.- See Also:
join(CompletableFuture)
-
join
public static <T> T join(java.util.concurrent.CompletableFuture<T> cf)
Waits for theCompletableFutureto complete.Any non
RuntimeExceptionthrown is converted to aRuntimeException.- Type Parameters:
T- The value type.- Parameters:
cf- TheCompletableFuture- Returns:
- The value of the completed
CompletableFuture.
-
completedNull
public static <T> java.util.concurrent.CompletableFuture<T> completedNull()
AnullcompletedCompletableFuture.- Type Parameters:
T- The value type.- Returns:
- The
CompletableFuture.
-
voidConsumer
public static <T> java.util.function.Consumer<T> voidConsumer()
Consumes any value and return aVoid.- Type Parameters:
T- The value type.- Returns:
- The
Consumer.
-
wrapAsCompletionException
public static java.util.concurrent.CompletionException wrapAsCompletionException(java.lang.Throwable throwable)
Wraps thethrowableintoCompletionException.- Parameters:
throwable- TheThrowableto wrap.- Returns:
- The
CompletionExceptionwiththrowable.
-
toVoidFunction
public static <T> java.util.function.Function<T,java.lang.Void> toVoidFunction()
- Type Parameters:
T- The value's type.- Returns:
- A
Functionthat converts any value toVoid.
-
completedTrue
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedTrue()
- Returns:
- A
CompletableFuturecompleted with valueBoolean.TRUE
-
completedFalse
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedFalse()
- Returns:
- A
CompletableFuturecompleted with valueBoolean.FALSE
-
-