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 withCompletableFuture
andCompletionStage
useful 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()
Anull
completedCompletableFuture
.static java.util.concurrent.CompletableFuture<java.lang.Boolean>
completedTrue()
static <T> T
join(java.util.concurrent.CompletableFuture<T> cf)
Waits for theCompletableFuture
to complete.static <T> T
join(java.util.concurrent.CompletionStage<T> cs)
Same asjoin(CompletableFuture)
but it receives aCompletionStage
as parameter.static <T> java.util.function.Function<T,java.lang.Void>
toVoidFunction()
static CompletableFutures
valueOf(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.CompletionException
wrapAsCompletionException(java.lang.Throwable throwable)
Wraps thethrowable
intoCompletionException
.
-
-
-
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 aCompletionStage
as parameter.- See Also:
join(CompletableFuture)
-
join
public static <T> T join(java.util.concurrent.CompletableFuture<T> cf)
Waits for theCompletableFuture
to complete.Any non
RuntimeException
thrown 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()
Anull
completedCompletableFuture
.- 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 thethrowable
intoCompletionException
.- Parameters:
throwable
- TheThrowable
to wrap.- Returns:
- The
CompletionException
withthrowable
.
-
toVoidFunction
public static <T> java.util.function.Function<T,java.lang.Void> toVoidFunction()
- Type Parameters:
T
- The value's type.- Returns:
- A
Function
that converts any value toVoid
.
-
completedTrue
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedTrue()
- Returns:
- A
CompletableFuture
completed with valueBoolean.TRUE
-
completedFalse
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedFalse()
- Returns:
- A
CompletableFuture
completed with valueBoolean.FALSE
-
-