/** * Gets the value of a completed stage. * * @param stage a completed {@link CompletionStage} * @param <T> the type of the value that the stage completes into * @return the value of the stage if it has one * @throws IllegalStateException if the stage is not completed * @since 0.1.0 */ public static <T> T getCompleted(CompletionStage<T> stage) { CompletableFuture<T> future = stage.toCompletableFuture(); checkCompleted(future); return future.join(); }
/** * Gets the value of a completed stage. * * @param stage a completed {@link CompletionStage} * @param <T> the type of the value that the stage completes into * @return the value of the stage if it has one * @throws IllegalStateException if the stage is not completed * @since 0.1.0 */ public static <T> T getCompleted(CompletionStage<T> stage) { CompletableFuture<T> future = stage.toCompletableFuture(); checkCompleted(future); return future.join(); }