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


Java CompletionStage.thenApply方法代码示例

本文整理汇总了Java中java.util.concurrent.CompletionStage.thenApply方法的典型用法代码示例。如果您正苦于以下问题:Java CompletionStage.thenApply方法的具体用法?Java CompletionStage.thenApply怎么用?Java CompletionStage.thenApply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.CompletionStage的用法示例。


在下文中一共展示了CompletionStage.thenApply方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: index

import java.util.concurrent.CompletionStage; //导入方法依赖的package包/类
/**
 * @return Service health details.
 */
public CompletionStage<Result> index() {
    Status storageClientStatus = this.storageClient.ping();
    CompletionStage<Status> keyValueStorageStatusResult = this.keyValueClient.pingAsync();

    return keyValueStorageStatusResult
        .thenApply(keyValueStatus -> ok(toJson(
            new StatusApiModel(storageClientStatus, keyValueStatus))));
}
 
开发者ID:Azure,项目名称:device-telemetry-java,代码行数:12,代码来源:StatusController.java

示例2: thenStage

import java.util.concurrent.CompletionStage; //导入方法依赖的package包/类
@Override
public <U> StagedFutureTimeout<U> thenStage(CompletionStage<U> stage) {
    // async isn't necessary - it's just a conversion to optional
    return new StagedFutureImpl<>(stage.thenApply(Optional::of), executor, tracing);
}
 
开发者ID:soabase,项目名称:soabase-stages,代码行数:6,代码来源:StagedFutureBuilderImpl.java

示例3: whenSucceeded

import java.util.concurrent.CompletionStage; //导入方法依赖的package包/类
/**
 * Return a new CompletionStage that calls the given handler iff the given stage
 * completes successfully with an {@link Optional} that is not empty.
 *
 * @param stage the stage to wrap
 * @param handler success handler - called only when the given stage returns a non-empty Optional
 * @return new CompletionStage
 */
public static <T, U> CompletionStage<Optional<U>> whenSucceeded(CompletionStage<Optional<T>> stage, Function<T, Optional<U>> handler)
{
    return stage.thenApply(optional -> optional.flatMap(handler));
}
 
开发者ID:soabase,项目名称:soabase-stages,代码行数:13,代码来源:Aborted.java

示例4: whenAborted

import java.util.concurrent.CompletionStage; //导入方法依赖的package包/类
/**
 * Return a new CompletionStage that calls the given handler iff the given stage
 * completes successfully with an {@link Optional} that is empty.
 *
 * @param stage the stage to wrap
 * @param handler success handler - called only when the given stage returns an empty Optional
 * @return new CompletionStage
 */
public static <T, U> CompletionStage<Optional<U>> whenAborted(CompletionStage<Optional<T>> stage, Supplier<Optional<U>> handler)
{
    return stage.thenApply(optional -> optional.isPresent() ? Optional.empty() : handler.get());
}
 
开发者ID:soabase,项目名称:soabase-stages,代码行数:13,代码来源:Aborted.java


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