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


Java Graph类代码示例

本文整理汇总了Java中akka.stream.Graph的典型用法代码示例。如果您正苦于以下问题:Java Graph类的具体用法?Java Graph怎么用?Java Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: filter

import akka.stream.Graph; //导入依赖的package包/类
/**
 * Creates a flow that feeds each event into [selector], and:
 * - If the selector emits a result, that result, and further results that also match, are fed through [target], and then merged into the stream.
 * - If the selector emits {@link ReadProtocol#none()}, the event is passed downstream unchanged
 * - If the selector emits a failure, the stream is failed.
 */
public static <E> Flow<E, E, NotUsed> filter(ReadProtocol<E,E> selector, Graph<FlowShape<E,E>, ?> target) {
    return Flow
        .<E>create()
        .via(insertMarkers(selector))
        .splitWhen(Marker.class::isInstance)
        .prefixAndTail(1)
        .flatMapConcat(t -> {
            // This is safe because all of the "tail" in "prefixAndTail" above comes from the original stream of E.
            Source<E, NotUsed> source = uncheckedCast(t.second());
            return isSelected(t.first().get(0)) ? source.via(target) : source;
        })
        .concatSubstreams();
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:20,代码来源:ProtocolFilter.java


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