xref: /aosp_15_r20/external/grpc-grpc-java/compiler/src/test/golden/TestDeprecatedService.java.txt (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1package io.grpc.testing.compiler;
2
3import static io.grpc.MethodDescriptor.generateFullMethodName;
4
5/**
6 * <pre>
7 * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
8 * </pre>
9 */
10@javax.annotation.Generated(
11    value = "by gRPC proto compiler (version 1.56.1-SNAPSHOT)",
12    comments = "Source: grpc/testing/compiler/test.proto")
13@io.grpc.stub.annotations.GrpcGenerated
14@java.lang.Deprecated
15public final class TestDeprecatedServiceGrpc {
16
17  private TestDeprecatedServiceGrpc() {}
18
19  public static final String SERVICE_NAME = "grpc.testing.compiler.TestDeprecatedService";
20
21  // Static method descriptors that strictly reflect the proto.
22  private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
23      io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod;
24
25  @io.grpc.stub.annotations.RpcMethod(
26      fullMethodName = SERVICE_NAME + '/' + "DeprecatedMethod",
27      requestType = io.grpc.testing.compiler.Test.SimpleRequest.class,
28      responseType = io.grpc.testing.compiler.Test.SimpleResponse.class,
29      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
30  public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest,
31      io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod() {
32    io.grpc.MethodDescriptor<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse> getDeprecatedMethodMethod;
33    if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
34      synchronized (TestDeprecatedServiceGrpc.class) {
35        if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
36          TestDeprecatedServiceGrpc.getDeprecatedMethodMethod = getDeprecatedMethodMethod =
37              io.grpc.MethodDescriptor.<io.grpc.testing.compiler.Test.SimpleRequest, io.grpc.testing.compiler.Test.SimpleResponse>newBuilder()
38              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
39              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeprecatedMethod"))
40              .setSampledToLocalTracing(true)
41              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
42                  io.grpc.testing.compiler.Test.SimpleRequest.getDefaultInstance()))
43              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
44                  io.grpc.testing.compiler.Test.SimpleResponse.getDefaultInstance()))
45              .setSchemaDescriptor(new TestDeprecatedServiceMethodDescriptorSupplier("DeprecatedMethod"))
46              .build();
47        }
48      }
49    }
50    return getDeprecatedMethodMethod;
51  }
52
53  /**
54   * Creates a new async stub that supports all call types for the service
55   */
56  public static TestDeprecatedServiceStub newStub(io.grpc.Channel channel) {
57    io.grpc.stub.AbstractStub.StubFactory<TestDeprecatedServiceStub> factory =
58      new io.grpc.stub.AbstractStub.StubFactory<TestDeprecatedServiceStub>() {
59        @java.lang.Override
60        public TestDeprecatedServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
61          return new TestDeprecatedServiceStub(channel, callOptions);
62        }
63      };
64    return TestDeprecatedServiceStub.newStub(factory, channel);
65  }
66
67  /**
68   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
69   */
70  public static TestDeprecatedServiceBlockingStub newBlockingStub(
71      io.grpc.Channel channel) {
72    io.grpc.stub.AbstractStub.StubFactory<TestDeprecatedServiceBlockingStub> factory =
73      new io.grpc.stub.AbstractStub.StubFactory<TestDeprecatedServiceBlockingStub>() {
74        @java.lang.Override
75        public TestDeprecatedServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
76          return new TestDeprecatedServiceBlockingStub(channel, callOptions);
77        }
78      };
79    return TestDeprecatedServiceBlockingStub.newStub(factory, channel);
80  }
81
82  /**
83   * Creates a new ListenableFuture-style stub that supports unary calls on the service
84   */
85  public static TestDeprecatedServiceFutureStub newFutureStub(
86      io.grpc.Channel channel) {
87    io.grpc.stub.AbstractStub.StubFactory<TestDeprecatedServiceFutureStub> factory =
88      new io.grpc.stub.AbstractStub.StubFactory<TestDeprecatedServiceFutureStub>() {
89        @java.lang.Override
90        public TestDeprecatedServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
91          return new TestDeprecatedServiceFutureStub(channel, callOptions);
92        }
93      };
94    return TestDeprecatedServiceFutureStub.newStub(factory, channel);
95  }
96
97  /**
98   * <pre>
99   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
100   * </pre>
101   */
102  @java.lang.Deprecated
103  public interface AsyncService {
104
105    /**
106     * <pre>
107     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
108     * </pre>
109     */
110    @java.lang.Deprecated
111    default void deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request,
112        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
113      io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getDeprecatedMethodMethod(), responseObserver);
114    }
115  }
116
117  /**
118   * Base class for the server implementation of the service TestDeprecatedService.
119   * <pre>
120   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
121   * </pre>
122   */
123  @java.lang.Deprecated
124  public static abstract class TestDeprecatedServiceImplBase
125      implements io.grpc.BindableService, AsyncService {
126
127    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
128      return TestDeprecatedServiceGrpc.bindService(this);
129    }
130  }
131
132  /**
133   * A stub to allow clients to do asynchronous rpc calls to service TestDeprecatedService.
134   * <pre>
135   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
136   * </pre>
137   */
138  @java.lang.Deprecated
139  public static final class TestDeprecatedServiceStub
140      extends io.grpc.stub.AbstractAsyncStub<TestDeprecatedServiceStub> {
141    private TestDeprecatedServiceStub(
142        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
143      super(channel, callOptions);
144    }
145
146    @java.lang.Override
147    protected TestDeprecatedServiceStub build(
148        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
149      return new TestDeprecatedServiceStub(channel, callOptions);
150    }
151
152    /**
153     * <pre>
154     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
155     * </pre>
156     */
157    @java.lang.Deprecated
158    public void deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request,
159        io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse> responseObserver) {
160      io.grpc.stub.ClientCalls.asyncUnaryCall(
161          getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request, responseObserver);
162    }
163  }
164
165  /**
166   * A stub to allow clients to do synchronous rpc calls to service TestDeprecatedService.
167   * <pre>
168   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
169   * </pre>
170   */
171  @java.lang.Deprecated
172  public static final class TestDeprecatedServiceBlockingStub
173      extends io.grpc.stub.AbstractBlockingStub<TestDeprecatedServiceBlockingStub> {
174    private TestDeprecatedServiceBlockingStub(
175        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
176      super(channel, callOptions);
177    }
178
179    @java.lang.Override
180    protected TestDeprecatedServiceBlockingStub build(
181        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
182      return new TestDeprecatedServiceBlockingStub(channel, callOptions);
183    }
184
185    /**
186     * <pre>
187     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
188     * </pre>
189     */
190    @java.lang.Deprecated
191    public io.grpc.testing.compiler.Test.SimpleResponse deprecatedMethod(io.grpc.testing.compiler.Test.SimpleRequest request) {
192      return io.grpc.stub.ClientCalls.blockingUnaryCall(
193          getChannel(), getDeprecatedMethodMethod(), getCallOptions(), request);
194    }
195  }
196
197  /**
198   * A stub to allow clients to do ListenableFuture-style rpc calls to service TestDeprecatedService.
199   * <pre>
200   * Test service that has been deprecated and should generate with Java's &#64;Deprecated annotation
201   * </pre>
202   */
203  @java.lang.Deprecated
204  public static final class TestDeprecatedServiceFutureStub
205      extends io.grpc.stub.AbstractFutureStub<TestDeprecatedServiceFutureStub> {
206    private TestDeprecatedServiceFutureStub(
207        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
208      super(channel, callOptions);
209    }
210
211    @java.lang.Override
212    protected TestDeprecatedServiceFutureStub build(
213        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
214      return new TestDeprecatedServiceFutureStub(channel, callOptions);
215    }
216
217    /**
218     * <pre>
219     * An RPC method that has been deprecated and should generate with Java's &#64;Deprecated annotation
220     * </pre>
221     */
222    @java.lang.Deprecated
223    public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.Test.SimpleResponse> deprecatedMethod(
224        io.grpc.testing.compiler.Test.SimpleRequest request) {
225      return io.grpc.stub.ClientCalls.futureUnaryCall(
226          getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request);
227    }
228  }
229
230  private static final int METHODID_DEPRECATED_METHOD = 0;
231
232  private static final class MethodHandlers<Req, Resp> implements
233      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
234      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
235      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
236      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
237    private final AsyncService serviceImpl;
238    private final int methodId;
239
240    MethodHandlers(AsyncService serviceImpl, int methodId) {
241      this.serviceImpl = serviceImpl;
242      this.methodId = methodId;
243    }
244
245    @java.lang.Override
246    @java.lang.SuppressWarnings("unchecked")
247    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
248      switch (methodId) {
249        case METHODID_DEPRECATED_METHOD:
250          serviceImpl.deprecatedMethod((io.grpc.testing.compiler.Test.SimpleRequest) request,
251              (io.grpc.stub.StreamObserver<io.grpc.testing.compiler.Test.SimpleResponse>) responseObserver);
252          break;
253        default:
254          throw new AssertionError();
255      }
256    }
257
258    @java.lang.Override
259    @java.lang.SuppressWarnings("unchecked")
260    public io.grpc.stub.StreamObserver<Req> invoke(
261        io.grpc.stub.StreamObserver<Resp> responseObserver) {
262      switch (methodId) {
263        default:
264          throw new AssertionError();
265      }
266    }
267  }
268
269  public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) {
270    return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
271        .addMethod(
272          getDeprecatedMethodMethod(),
273          io.grpc.stub.ServerCalls.asyncUnaryCall(
274            new MethodHandlers<
275              io.grpc.testing.compiler.Test.SimpleRequest,
276              io.grpc.testing.compiler.Test.SimpleResponse>(
277                service, METHODID_DEPRECATED_METHOD)))
278        .build();
279  }
280
281  private static abstract class TestDeprecatedServiceBaseDescriptorSupplier
282      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
283    TestDeprecatedServiceBaseDescriptorSupplier() {}
284
285    @java.lang.Override
286    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
287      return io.grpc.testing.compiler.Test.getDescriptor();
288    }
289
290    @java.lang.Override
291    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
292      return getFileDescriptor().findServiceByName("TestDeprecatedService");
293    }
294  }
295
296  private static final class TestDeprecatedServiceFileDescriptorSupplier
297      extends TestDeprecatedServiceBaseDescriptorSupplier {
298    TestDeprecatedServiceFileDescriptorSupplier() {}
299  }
300
301  private static final class TestDeprecatedServiceMethodDescriptorSupplier
302      extends TestDeprecatedServiceBaseDescriptorSupplier
303      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
304    private final String methodName;
305
306    TestDeprecatedServiceMethodDescriptorSupplier(String methodName) {
307      this.methodName = methodName;
308    }
309
310    @java.lang.Override
311    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
312      return getServiceDescriptor().findMethodByName(methodName);
313    }
314  }
315
316  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
317
318  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
319    io.grpc.ServiceDescriptor result = serviceDescriptor;
320    if (result == null) {
321      synchronized (TestDeprecatedServiceGrpc.class) {
322        result = serviceDescriptor;
323        if (result == null) {
324          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
325              .setSchemaDescriptor(new TestDeprecatedServiceFileDescriptorSupplier())
326              .addMethod(getDeprecatedMethodMethod())
327              .build();
328        }
329      }
330    }
331    return result;
332  }
333}
334