Merge pull request #18842 from ktoso/wip-add-of-ktoso
+str #18840 add of method to predefined Shapes, for nicer Java use
This commit is contained in:
commit
e2b98da865
2 changed files with 27 additions and 5 deletions
|
|
@ -78,22 +78,22 @@ public class MigrationsJava {
|
||||||
//#graph-create-2
|
//#graph-create-2
|
||||||
FlowGraph.create(builder -> {
|
FlowGraph.create(builder -> {
|
||||||
//...
|
//...
|
||||||
return new SourceShape<>(outlet);
|
return SourceShape.of(outlet);
|
||||||
});
|
});
|
||||||
|
|
||||||
FlowGraph.create(builder -> {
|
FlowGraph.create(builder -> {
|
||||||
//...
|
//...
|
||||||
return new SinkShape<>(inlet);
|
return SinkShape.of(inlet);
|
||||||
});
|
});
|
||||||
|
|
||||||
FlowGraph.create(builder -> {
|
FlowGraph.create(builder -> {
|
||||||
//...
|
//...
|
||||||
return new FlowShape<>(inlet, outlet);
|
return FlowShape.of(inlet, outlet);
|
||||||
});
|
});
|
||||||
|
|
||||||
FlowGraph.create(builder -> {
|
FlowGraph.create(builder -> {
|
||||||
//...
|
//...
|
||||||
return new BidiShape<>(inlet1, outlet1, inlet2, outlet2);
|
return BidiShape.of(inlet1, outlet1, inlet2, outlet2);
|
||||||
});
|
});
|
||||||
//#graph-create-2
|
//#graph-create-2
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,11 @@ final case class SourceShape[+T](outlet: Outlet[T @uncheckedVariance]) extends S
|
||||||
SourceShape(outlets.head)
|
SourceShape(outlets.head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
object SourceShape {
|
||||||
|
/** Java API */
|
||||||
|
def of[T](outlet: Outlet[T @uncheckedVariance]): SourceShape[T] =
|
||||||
|
SourceShape(outlet)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Flow [[Shape]] has exactly one input and one output, it looks from the
|
* A Flow [[Shape]] has exactly one input and one output, it looks from the
|
||||||
|
|
@ -223,6 +228,11 @@ final case class FlowShape[-I, +O](inlet: Inlet[I @uncheckedVariance], outlet: O
|
||||||
FlowShape(inlets.head, outlets.head)
|
FlowShape(inlets.head, outlets.head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
object FlowShape {
|
||||||
|
/** Java API */
|
||||||
|
def of[I, O](inlet: Inlet[I @uncheckedVariance], outlet: Outlet[O @uncheckedVariance]): FlowShape[I, O] =
|
||||||
|
FlowShape(inlet, outlet)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Sink [[Shape]] has exactly one input and no outputs, it models a data sink.
|
* A Sink [[Shape]] has exactly one input and no outputs, it models a data sink.
|
||||||
|
|
@ -238,6 +248,11 @@ final case class SinkShape[-T](inlet: Inlet[T @uncheckedVariance]) extends Shape
|
||||||
SinkShape(inlets.head)
|
SinkShape(inlets.head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
object SinkShape {
|
||||||
|
/** Java API */
|
||||||
|
def of[T](inlet: Inlet[T @uncheckedVariance]): SinkShape[T] =
|
||||||
|
SinkShape(inlet)
|
||||||
|
}
|
||||||
|
|
||||||
//#bidi-shape
|
//#bidi-shape
|
||||||
/**
|
/**
|
||||||
|
|
@ -276,8 +291,15 @@ final case class BidiShape[-In1, +Out1, -In2, +Out2](in1: Inlet[In1 @uncheckedVa
|
||||||
//#implementation-details-elided
|
//#implementation-details-elided
|
||||||
}
|
}
|
||||||
//#bidi-shape
|
//#bidi-shape
|
||||||
|
|
||||||
object BidiShape {
|
object BidiShape {
|
||||||
def fromFlows[I1, O1, I2, O2](top: FlowShape[I1, O1], bottom: FlowShape[I2, O2]): BidiShape[I1, O1, I2, O2] =
|
def fromFlows[I1, O1, I2, O2](top: FlowShape[I1, O1], bottom: FlowShape[I2, O2]): BidiShape[I1, O1, I2, O2] =
|
||||||
BidiShape(top.inlet, top.outlet, bottom.inlet, bottom.outlet)
|
BidiShape(top.inlet, top.outlet, bottom.inlet, bottom.outlet)
|
||||||
|
|
||||||
|
/** Java API */
|
||||||
|
def of[In1, Out1, In2, Out2](in1: Inlet[In1 @uncheckedVariance],
|
||||||
|
out1: Outlet[Out1 @uncheckedVariance],
|
||||||
|
in2: Inlet[In2 @uncheckedVariance],
|
||||||
|
out2: Outlet[Out2 @uncheckedVariance]): BidiShape[In1, Out1, In2, Out2] =
|
||||||
|
BidiShape(in1, out1, in2, out2)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue