當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。