#19441: Use Optional instead of Option in javadsl
This commit is contained in:
parent
ecc916abfd
commit
7a39063f2e
7 changed files with 48 additions and 68 deletions
|
|
@ -5,10 +5,7 @@ package docs.stream;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
|
@ -225,7 +222,7 @@ public class FlowDocTest {
|
|||
//#flow-mat-combine
|
||||
|
||||
// An empty source that can be shut down explicitly from the outside
|
||||
Source<Integer, Promise<Option<Integer>>> source = Source.<Integer>maybe();
|
||||
Source<Integer, Promise<Optional<Integer>>> source = Source.<Integer>maybe();
|
||||
|
||||
// A flow that internally throttles elements to 1/second, and returns a Cancellable
|
||||
// which can be used to shut down the stream
|
||||
|
|
@ -236,7 +233,7 @@ public class FlowDocTest {
|
|||
|
||||
|
||||
// By default, the materialized value of the leftmost stage is preserved
|
||||
RunnableGraph<Promise<Option<Integer>>> r1 = source.via(flow).to(sink);
|
||||
RunnableGraph<Promise<Optional<Integer>>> r1 = source.via(flow).to(sink);
|
||||
|
||||
// Simple selection of materialized values by using Keep.right
|
||||
RunnableGraph<Cancellable> r2 = source.viaMat(flow, Keep.right()).to(sink);
|
||||
|
|
@ -245,17 +242,17 @@ public class FlowDocTest {
|
|||
// Using runWith will always give the materialized values of the stages added
|
||||
// by runWith() itself
|
||||
Future<Integer> r4 = source.via(flow).runWith(sink, mat);
|
||||
Promise<Option<Integer>> r5 = flow.to(sink).runWith(source, mat);
|
||||
Pair<Promise<Option<Integer>>, Future<Integer>> r6 = flow.runWith(source, sink, mat);
|
||||
Promise<Optional<Integer>> r5 = flow.to(sink).runWith(source, mat);
|
||||
Pair<Promise<Optional<Integer>>, Future<Integer>> r6 = flow.runWith(source, sink, mat);
|
||||
|
||||
// Using more complext combinations
|
||||
RunnableGraph<Pair<Promise<Option<Integer>>, Cancellable>> r7 =
|
||||
RunnableGraph<Pair<Promise<Optional<Integer>>, Cancellable>> r7 =
|
||||
source.viaMat(flow, Keep.both()).to(sink);
|
||||
|
||||
RunnableGraph<Pair<Promise<Option<Integer>>, Future<Integer>>> r8 =
|
||||
RunnableGraph<Pair<Promise<Optional<Integer>>, Future<Integer>>> r8 =
|
||||
source.via(flow).toMat(sink, Keep.both());
|
||||
|
||||
RunnableGraph<Pair<Pair<Promise<Option<Integer>>, Cancellable>, Future<Integer>>> r9 =
|
||||
RunnableGraph<Pair<Pair<Promise<Optional<Integer>>, Cancellable>, Future<Integer>>> r9 =
|
||||
source.viaMat(flow, Keep.both()).toMat(sink, Keep.both());
|
||||
|
||||
RunnableGraph<Pair<Cancellable, Future<Integer>>> r10 =
|
||||
|
|
@ -267,7 +264,7 @@ public class FlowDocTest {
|
|||
|
||||
RunnableGraph<Cancellable> r11 =
|
||||
r9.mapMaterializedValue( (nestedTuple) -> {
|
||||
Promise<Option<Integer>> p = nestedTuple.first().first();
|
||||
Promise<Optional<Integer>> p = nestedTuple.first().first();
|
||||
Cancellable c = nestedTuple.first().second();
|
||||
Future<Integer> f = nestedTuple.second();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue