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