23
23
/**
24
24
* Utility functions for working with {@link StreamObserver} and it's common subclasses like
25
25
* {@link CallStreamObserver}.
26
- *
27
- * @deprecated Of questionable utility and generally not used.
28
26
*/
29
- @ Deprecated
30
- @ ExperimentalApi ("https://github.com/grpc/grpc-java/issues/4694" )
31
27
public final class StreamObservers {
28
+ // Prevent instantiation
29
+ private StreamObservers () { }
30
+
31
+ /**
32
+ * Utility method to call {@link StreamObserver#onNext(Object)} and
33
+ * {@link StreamObserver#onCompleted()} on the specified responseObserver.
34
+ */
35
+ @ ExperimentalApi ("https://github.com/grpc/grpc-java/issues/10957" )
36
+ public static <T > void nextAndComplete (StreamObserver <T > responseObserver , T response ) {
37
+ responseObserver .onNext (response );
38
+ responseObserver .onCompleted ();
39
+ }
40
+
32
41
/**
33
42
* Copy the values of an {@link Iterator} to the target {@link CallStreamObserver} while properly
34
43
* accounting for outbound flow-control. After calling this method, {@code target} should no
@@ -40,7 +49,10 @@ public final class StreamObservers {
40
49
*
41
50
* @param source of values expressed as an {@link Iterator}.
42
51
* @param target {@link CallStreamObserver} which accepts values from the source.
52
+ * @deprecated Of questionable utility and generally not used.
43
53
*/
54
+ @ Deprecated
55
+ @ ExperimentalApi ("https://github.com/grpc/grpc-java/issues/4694" )
44
56
public static <V > void copyWithFlowControl (final Iterator <V > source ,
45
57
final CallStreamObserver <V > target ) {
46
58
Preconditions .checkNotNull (source , "source" );
@@ -80,7 +92,10 @@ public void run() {
80
92
*
81
93
* @param source of values expressed as an {@link Iterable}.
82
94
* @param target {@link CallStreamObserver} which accepts values from the source.
95
+ * @deprecated Of questionable utility and generally not used.
83
96
*/
97
+ @ Deprecated
98
+ @ ExperimentalApi ("https://github.com/grpc/grpc-java/issues/4694" )
84
99
public static <V > void copyWithFlowControl (final Iterable <V > source ,
85
100
CallStreamObserver <V > target ) {
86
101
Preconditions .checkNotNull (source , "source" );
0 commit comments