e.servicelibs.rxgrpc.0.8.1.source-code.RxStub.mustache Maven / Gradle / Ivy
{{#packageName}}
package {{packageName}};
{{/packageName}}
import static {{packageName}}.{{serviceName}}Grpc.getServiceDescriptor;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
{{#deprecated}}
@java.lang.Deprecated
{{/deprecated}}
@javax.annotation.Generated(
value = "by RxGrpc generator",
comments = "Source: {{protoName}}")
public final class {{className}} {
private {{className}}() {}
public static Rx{{serviceName}}Stub newRxStub(io.grpc.Channel channel) {
return new Rx{{serviceName}}Stub(channel);
}
{{#javaDoc}}
{{{javaDoc}}}
{{/javaDoc}}
public static final class Rx{{serviceName}}Stub extends io.grpc.stub.AbstractStub {
private {{serviceName}}Grpc.{{serviceName}}Stub delegateStub;
private Rx{{serviceName}}Stub(io.grpc.Channel channel) {
super(channel);
delegateStub = {{serviceName}}Grpc.newStub(channel);
}
private Rx{{serviceName}}Stub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
delegateStub = {{serviceName}}Grpc.newStub(channel).build(channel, callOptions);
}
@Override
protected Rx{{serviceName}}Stub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new Rx{{serviceName}}Stub(channel, callOptions);
}
{{#methods}}
{{#javaDoc}}
{{{javaDoc}}}
{{/javaDoc}}
{{#deprecated}}
@java.lang.Deprecated
{{/deprecated}}
public {{#isManyOutput}}io.reactivex.Flowable{{/isManyOutput}}{{^isManyOutput}}io.reactivex.Single{{/isManyOutput}}<{{outputType}}> {{methodName}}({{#isManyInput}}io.reactivex.Flowable{{/isManyInput}}{{^isManyInput}}io.reactivex.Single{{/isManyInput}}<{{inputType}}> rxRequest) {
return com.salesforce.rxgrpc.stub.ClientCalls.{{reactiveCallsMethodName}}(rxRequest, delegateStub::{{methodNameCamelCase}});
}
{{/methods}}
}
{{#javaDoc}}
{{{javaDoc}}}
{{/javaDoc}}
public static abstract class {{serviceName}}ImplBase implements io.grpc.BindableService {
{{#methods}}
{{#javaDoc}}
{{{javaDoc}}}
{{/javaDoc}}
{{#deprecated}}
@java.lang.Deprecated
{{/deprecated}}
public {{#isManyOutput}}io.reactivex.Flowable{{/isManyOutput}}{{^isManyOutput}}io.reactivex.Single{{/isManyOutput}}<{{outputType}}> {{methodNameCamelCase}}({{#isManyInput}}io.reactivex.Flowable{{/isManyInput}}{{^isManyInput}}io.reactivex.Single{{/isManyInput}}<{{inputType}}> request) {
throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED);
}
{{/methods}}
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
{{#methods}}
.addMethod(
{{packageName}}.{{serviceName}}Grpc.get{{methodNamePascalCase}}Method(),
{{grpcCallsMethodName}}(
new MethodHandlers<
{{inputType}},
{{outputType}}>(
this, METHODID_{{methodNameUpperUnderscore}})))
{{/methods}}
.build();
}
}
{{#methods}}
private static final int METHODID_{{methodNameUpperUnderscore}} = {{methodNumber}};
{{/methods}}
private static final class MethodHandlers implements
io.grpc.stub.ServerCalls.UnaryMethod,
io.grpc.stub.ServerCalls.ServerStreamingMethod,
io.grpc.stub.ServerCalls.ClientStreamingMethod,
io.grpc.stub.ServerCalls.BidiStreamingMethod {
private final {{serviceName}}ImplBase serviceImpl;
private final int methodId;
MethodHandlers({{serviceName}}ImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) {
switch (methodId) {
{{#methods}}
{{^isManyInput}}
case METHODID_{{methodNameUpperUnderscore}}:
com.salesforce.rxgrpc.stub.ServerCalls.{{reactiveCallsMethodName}}(({{inputType}}) request,
(io.grpc.stub.StreamObserver<{{outputType}}>) responseObserver,
serviceImpl::{{methodNameCamelCase}});
break;
{{/isManyInput}}
{{/methods}}
default:
throw new java.lang.AssertionError();
}
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver invoke(io.grpc.stub.StreamObserver responseObserver) {
switch (methodId) {
{{#methods}}
{{#isManyInput}}
case METHODID_{{methodNameUpperUnderscore}}:
return (io.grpc.stub.StreamObserver) com.salesforce.rxgrpc.stub.ServerCalls.{{reactiveCallsMethodName}}(
(io.grpc.stub.StreamObserver<{{outputType}}>) responseObserver,
serviceImpl::{{methodNameCamelCase}});
{{/isManyInput}}
{{/methods}}
default:
throw new java.lang.AssertionError();
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy