package docs; import akka.actor.Cancellable; import akka.http.javadsl.model.Uri; import akka.japi.Pair; import akka.japi.function.Function; import akka.stream.*; import akka.stream.javadsl.*; import akka.util.ByteString; import scala.Option; import scala.concurrent.Future; import scala.concurrent.duration.FiniteDuration; import scala.concurrent.Promise; import scala.runtime.BoxedUnit; import java.io.File; import java.util.concurrent.TimeUnit; import java.nio.charset.Charset; public class MigrationsJava { // This is compile-only code, no need for actually running anything. public static ActorMaterializer mat = null; public static void main(String[] args) { Outlet outlet = null; Outlet outlet1 = null; Outlet outlet2 = null; Inlet inlet = null; Inlet inlet1 = null; Inlet inlet2 = null; Flow flow = Flow.of(Integer.class); Flow flow1 = Flow.of(Integer.class); Flow flow2 = Flow.of(Integer.class); Promise> promise = null; { Graph, BoxedUnit> graphSource = null; Graph, BoxedUnit> graphSink = null; Graph, BoxedUnit> graphFlow = null; //#flow-wrap Source source = Source.fromGraph(graphSource); Sink sink = Sink.fromGraph(graphSink); Flow aflow = Flow.fromGraph(graphFlow); Flow.fromSinkAndSource(Sink.head(), Source.single(0)); Flow.fromSinkAndSourceMat(Sink.head(), Source.single(0), Keep.left()); //#flow-wrap Graph, BoxedUnit> bidiGraph = null; //#bidi-wrap BidiFlow bidiFlow = BidiFlow.fromGraph(bidiGraph); BidiFlow.fromFlows(flow1, flow2); BidiFlow.fromFlowsMat(flow1, flow2, Keep.both()); //#bidi-wrap } { //#graph-create FlowGraph.create(builder -> { //... return ClosedShape.getInstance(); }); FlowGraph.create(builder -> { //... return new FlowShape<>(inlet, outlet); }); //#graph-create } { //#graph-create-2 FlowGraph.create(builder -> { //... return SourceShape.of(outlet); }); FlowGraph.create(builder -> { //... return SinkShape.of(inlet); }); FlowGraph.create(builder -> { //... return FlowShape.of(inlet, outlet); }); FlowGraph.create(builder -> { //... return BidiShape.of(inlet1, outlet1, inlet2, outlet2); }); //#graph-create-2 } { //#graph-builder FlowGraph.create(builder -> { builder.from(outlet).toInlet(inlet); builder.from(outlet).via(builder.add(flow)).toInlet(inlet); builder.from(builder.add(Source.single(0))).to(builder.add(Sink.head())); //... return ClosedShape.getInstance(); }); //#graph-builder } //#source-creators Source>> src = Source.maybe(); // Complete the promise with an empty option to emulate the old lazyEmpty promise.trySuccess(scala.Option.empty()); final Source sourceUnderTest = Source.tick( FiniteDuration.create(0, TimeUnit.MILLISECONDS), FiniteDuration.create(200, TimeUnit.MILLISECONDS), "tick"); //#source-creators //#empty-flow Flow emptyFlow = Flow.create(); // or Flow emptyFlow2 = Flow.of(Integer.class); //#empty-flow //#flatMapConcat Flow.>create(). flatMapConcat(new Function, Source>(){ @Override public Source apply(Source param) throws Exception { return param; } }); //#flatMapConcat Uri uri = null; //#raw-query final akka.japi.Option theRawQueryString = uri.rawQueryString(); //#raw-query //#query-param final akka.japi.Option aQueryParam = uri.query().get("a"); //#query-param //#file-source-sink final Source> fileSrc = Source.file(new File(".")); final Source> otherFileSrc = Source.file(new File("."), 1024); final Sink> fileSink = Sink.file(new File(".")); //#file-source-sink } }