1 /*
2  * Copyright 2018 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc.stub.annotations;
18 
19 import io.grpc.MethodDescriptor;
20 import java.lang.annotation.ElementType;
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 import java.lang.annotation.Target;
24 
25 /**
26  * {@link RpcMethod} contains a limited subset of information about the RPC to assist
27  * <a href="https://docs.oracle.com/javase/6/docs/api/javax/annotation/processing/Processor.html">
28  * Java Annotation Processors.</a>
29  *
30  * <p>
31  *   This annotation is used by the gRPC stub compiler to annotate {@link MethodDescriptor}
32  *   getters.  Users should not annotate their own classes with this annotation.  Not all stubs may
33  *   have this annotation, so consumers should not assume that it is present.
34  * </p>
35  *
36  * @since 1.14.0
37  */
38 @Retention(RetentionPolicy.CLASS)
39 @Target(ElementType.METHOD)
40 public @interface RpcMethod {
41 
42   /**
43    * The fully qualified method name.  This should match the name as returned by
44    * {@link MethodDescriptor#generateFullMethodName(String, String)}.
45    */
fullMethodName()46   String fullMethodName();
47 
48   /**
49    * The request type of the method.  The request type class should be assignable from (i.e.
50    * {@link Class#isAssignableFrom(Class)} the request type {@code ReqT} of the
51    * {@link MethodDescriptor}.  Additionally, if the request {@code MethodDescriptor.Marshaller}
52    * is a {@code MethodDescriptor.ReflectableMarshaller}, the request type should be assignable
53    * from {@code MethodDescriptor.ReflectableMarshaller#getMessageClass()}.
54    */
requestType()55   Class<?> requestType();
56 
57   /**
58    * The response type of the method.  The response type class should be assignable from (i.e.
59    * {@link Class#isAssignableFrom(Class)} the response type {@code RespT} of the
60    * {@link MethodDescriptor}.  Additionally, if the response {@code MethodDescriptor.Marshaller}
61    * is a {@code MethodDescriptor.ReflectableMarshaller}, the response type should be assignable
62    * from {@code MethodDescriptor.ReflectableMarshaller#getMessageClass()}.
63    */
responseType()64   Class<?> responseType();
65 
66   /**
67    * The call type of the method.
68    */
methodType()69   MethodDescriptor.MethodType methodType();
70 }
71