Class StateCheckingResponseObserver<V> (2.53.0)

public abstract class StateCheckingResponseObserver<V> implements ResponseObserver<V>

Base implementation of ResponseObserver that performs state sanity checks.

Inheritance

java.lang.Object > StateCheckingResponseObserver<V>

Implements

com.google.api.gax.rpc.ResponseObserver<V>

Type Parameter

Name Description
V

Constructors

StateCheckingResponseObserver()

public StateCheckingResponseObserver()

Methods

onComplete()

public final void onComplete()

Receives a notification of successful stream completion.

May only be called once, and if called, it must be the last method called. In particular, if an exception is thrown by an implementation of onComplete, no further calls to any method are allowed.

This implementation simply delegates to #onCompleteImpl() after ensuring consistent state.

onCompleteImpl()

protected abstract void onCompleteImpl()

See Also: #onComplete()

onError(Throwable t)

public final void onError(Throwable t)

Receives a terminating error from the stream.

May only be called once, and if called, it must be the last method called. In particular, if an exception is thrown by an implementation of onError, no further calls to any method are allowed.

This implementation simply delegates to #onErrorImpl(Throwable) after ensuring consistent state.

Parameter
Name Description
t Throwable

onErrorImpl(Throwable t)

protected abstract void onErrorImpl(Throwable t)
Parameter
Name Description
t Throwable

onResponse(V response)

public final void onResponse(V response)

Receives a value from the stream.

Can be called many times but is never called after #onError(Throwable) or #onComplete() are called.

Clients may may receive 0 or more onResponse callbacks.

If an exception is thrown by an implementation the caller will terminate the stream by calling #onError(Throwable) with the caught exception as the cause.

This implementation simply delegates to #onResponseImpl(Object) after ensuring consistent state.

Parameter
Name Description
response V

onResponseImpl(V response)

protected abstract void onResponseImpl(V response)
Parameter
Name Description
response V

onStart(StreamController controller)

public final void onStart(StreamController controller)

Called before the stream is started. This must be invoked synchronously on the same thread that called ServerStreamingCallable#call(Object, ResponseObserver, ApiCallContext)

Allows for disabling flow control and early stream termination via StreamController.

This implementation simply delegates to #onStartImpl(StreamController) after ensuring consistent state.

Parameter
Name Description
controller StreamController

onStartImpl(StreamController controller)

protected abstract void onStartImpl(StreamController controller)
Parameter
Name Description
controller StreamController