当前位置: 首页>>代码示例>>Java>>正文


Java CompletionStage.thenCompose方法代码示例

本文整理汇总了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);
}
 
开发者ID:Tristan971,项目名称:EasyFXML,代码行数:10,代码来源:ExceptionHandler.java

示例2: updateBatches

import java.util.concurrent.CompletionStage; //导入方法依赖的package包/类
/**
 * Given a list of update actions batches represented by a {@link List}&lt;{@link List}&gt; 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}&lt;{@code U}&gt; 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;
}
 
开发者ID:commercetools,项目名称:commercetools-sync-java,代码行数:27,代码来源:BaseService.java

示例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));
}
 
开发者ID:commercetools,项目名称:commercetools-sync-java,代码行数:16,代码来源:QueryAll.java


注:本文中的java.util.concurrent.CompletionStage.thenCompose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。