I’m writing a ServerInterceptor
that might respond with a predefined response. In order to construct a response, I need a builder of that type but I can’t find a way to get it.
Here is the declaration of the method:
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
ServerCall<ReqT, RespT> call,
Metadata headers,
ServerCallHandler<ReqT, RespT> next) {
// how to get a builder of RespT here?
...
}
I found out that there is call.getMethodDescriptor().getResponseMarshaller()
method and if I cast it to ReflectableMarshaller<RespT>
, I can invoke getMessageClass()
to get Class
for a response. But how I can get a builder for that class then?