本文整理了Java中akka.stream.javadsl.Flow.collect()
方法的一些代码示例,展示了Flow.collect()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flow.collect()
方法的具体详情如下:
包路径:akka.stream.javadsl.Flow
类名称:Flow
方法名:collect
暂无
代码示例来源:origin: com.typesafe.play/play_2.12
@Override
public CompletionStage<F.Either<Result, Flow<Message, Message, ?>>> apply(Http.RequestHeader request) {
return f.apply(request).thenApply(resultOrFlow -> {
if (resultOrFlow.left.isPresent()) {
return F.Either.Left(resultOrFlow.left.get());
} else {
Flow<Message, Message, ?> flow = AkkaStreams.bypassWith(
Flow.<Message>create().collect(inMapper),
play.api.libs.streams.AkkaStreams.onlyFirstCanFinishMerge(2),
resultOrFlow.right.get().map(outMapper::apply)
);
return F.Either.Right(flow);
}
});
}
};
代码示例来源:origin: com.typesafe.play/play
@Override
public CompletionStage<F.Either<Result, Flow<Message, Message, ?>>> apply(Http.RequestHeader request) {
return f.apply(request).thenApply(resultOrFlow -> {
if (resultOrFlow.left.isPresent()) {
return F.Either.Left(resultOrFlow.left.get());
} else {
Flow<Message, Message, ?> flow = AkkaStreams.bypassWith(
Flow.<Message>create().collect(inMapper),
play.api.libs.streams.AkkaStreams.onlyFirstCanFinishMerge(2),
resultOrFlow.right.get().map(outMapper::apply)
);
return F.Either.Right(flow);
}
});
}
};
代码示例来源:origin: com.typesafe.play/play_2.11
@Override
public CompletionStage<F.Either<Result, Flow<Message, Message, ?>>> apply(Http.RequestHeader request) {
return f.apply(request).thenApply(resultOrFlow -> {
if (resultOrFlow.left.isPresent()) {
return F.Either.Left(resultOrFlow.left.get());
} else {
Flow<Message, Message, ?> flow = AkkaStreams.bypassWith(
Flow.<Message>create().collect(inMapper),
play.api.libs.streams.AkkaStreams.onlyFirstCanFinishMerge(2),
resultOrFlow.right.get().map(outMapper::apply)
);
return F.Either.Right(flow);
}
});
}
};
代码示例来源:origin: com.typesafe.play/play_2.12
UniformFanInShape<Out, Out> merge = builder.add(mergeStrategy);
Flow<F.Either<FlowIn, Out>, FlowIn, ?> collectIn = Flow.<F.Either<FlowIn, Out>>create().collect(Scala.partialFunction(x -> {
if (x.left.isPresent()) {
return x.left.get();
Flow<F.Either<FlowIn, Out>, Out, ?> collectOut = Flow.<F.Either<FlowIn, Out>>create().collect(Scala.partialFunction(x -> {
if (x.right.isPresent()) {
return x.right.get();
代码示例来源:origin: com.typesafe.play/play
UniformFanInShape<Out, Out> merge = builder.add(mergeStrategy);
Flow<F.Either<FlowIn, Out>, FlowIn, ?> collectIn = Flow.<F.Either<FlowIn, Out>>create().collect(Scala.partialFunction(x -> {
if (x.left.isPresent()) {
return x.left.get();
Flow<F.Either<FlowIn, Out>, Out, ?> collectOut = Flow.<F.Either<FlowIn, Out>>create().collect(Scala.partialFunction(x -> {
if (x.right.isPresent()) {
return x.right.get();
代码示例来源:origin: com.typesafe.play/play_2.11
UniformFanInShape<Out, Out> merge = builder.add(mergeStrategy);
Flow<F.Either<FlowIn, Out>, FlowIn, ?> collectIn = Flow.<F.Either<FlowIn, Out>>create().collect(Scala.partialFunction(x -> {
if (x.left.isPresent()) {
return x.left.get();
Flow<F.Either<FlowIn, Out>, Out, ?> collectOut = Flow.<F.Either<FlowIn, Out>>create().collect(Scala.partialFunction(x -> {
if (x.right.isPresent()) {
return x.right.get();
代码示例来源:origin: wxyyxc1992/Backend-Boilerplates
/**
* A handler that treats incoming messages as a name,
* and responds with a greeting to that name
*/
public static Flow<Message, Message, NotUsed> greeter() {
return
Flow.<Message>create()
.collect(new JavaPartialFunction<Message, Message>() {
@Override
public Message apply(Message msg, boolean isCheck) throws Exception {
if (isCheck) {
if (msg.isText()) {
return null;
} else {
throw noMatch();
}
} else {
return handleTextMessage(msg.asTextMessage());
}
}
});
}
内容来源于网络,如有侵权,请联系作者删除!