本文整理匯總了Java中java.util.concurrent.CompletionStage.thenCompose方法的典型用法代碼示例。如果您正苦於以下問題:Java CompletionStage.thenCompose方法的具體用法?Java CompletionStage.thenCompose怎麽用?Java CompletionStage.thenCompose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.CompletionStage
的用法示例。
在下文中一共展示了CompletionStage.thenCompose方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: displayExceptionPane
import java.util.concurrent.CompletionStage; //導入方法依賴的package包/類
public static CompletionStage<Stage> displayExceptionPane(
final String title,
final String readable,
final Throwable exception
) {
final Pane exceptionPane = new ExceptionHandler(exception).asPane(readable);
final CompletionStage<Stage> exceptionStage = Stages.stageOf(title, exceptionPane);
return exceptionStage.thenCompose(Stages::scheduleDisplaying);
}
示例2: updateBatches
import java.util.concurrent.CompletionStage; //導入方法依賴的package包/類
/**
* Given a list of update actions batches represented by a {@link List}<{@link List}> of {@link UpdateAction},
* this method executes the update command, computed by {@code updateCommandFunction}, on each batch.
*
* @param result in the first call of this method, this result is normally a completed
* future containing the resource to update, it is then used within each iteration of
* batch execution to have the latest resource (with version) once the previous batch
* has finished execution.
* @param updateCommandFunction a {@link BiFunction} used to compute the update command required to update the
* resource.
* @param batches the batches of update actions to execute.
* @return an instance of {@link CompletionStage}<{@code U}> which contains as a result an instance of
* the resource {@link U} after all the update actions in all batches have been executed.
*/
@Nonnull
private CompletionStage<U> updateBatches(
@Nonnull final CompletionStage<U> result,
@Nonnull final BiFunction<U, List<? extends UpdateAction<U>>, UpdateCommand<U>> updateCommandFunction,
@Nonnull final List<List<UpdateAction<U>>> batches) {
CompletionStage<U> resultStage = result;
for (final List<UpdateAction<U>> batch : batches) {
resultStage = resultStage.thenCompose(updatedProduct ->
syncOptions.getCtpClient().execute(updateCommandFunction.apply(updatedProduct, batch)));
}
return resultStage;
}
示例3: queryNextPages
import java.util.concurrent.CompletionStage; //導入方法依賴的package包/類
/**
* Given a completion stage {@code currentPageStage} containing a current page result {@link PagedQueryResult}, this
* method composes the completion stage by first checking if the result is null or not. If it is not, then it
* recursivley (by calling itself with the next page's completion stage result) composes to the supplied stage,
* stages of the all next pages' processing. If there is no next page, then the result of the
* {@code currentPageStage} would be null and this method would just return a completed future containing
* containing null result, which in turn signals the last page of processing.
*
* @param currentPageStage a future containing a result {@link PagedQueryResult}.
*/
@Nonnull
private CompletionStage<Void> queryNextPages(@Nonnull final CompletionStage<PagedQueryResult<T>> currentPageStage) {
return currentPageStage.thenCompose(currentPage ->
currentPage != null ? queryNextPages(processPageAndGetNext(currentPage)) : completedFuture(null));
}