@@ -52,14 +52,14 @@ public List<MethodMetadata> parseAndValidateMetadata(Class<?> targetType) {
5252 "Only single-level inheritance supported: %s" ,
5353 targetType .getSimpleName ());
5454 }
55- Map <String , MethodMetadata > result = new LinkedHashMap <String , MethodMetadata >();
56- for (Method method : targetType .getMethods ()) {
55+ final Map <String , MethodMetadata > result = new LinkedHashMap <String , MethodMetadata >();
56+ for (final Method method : targetType .getMethods ()) {
5757 if (method .getDeclaringClass () == Object .class ||
5858 (method .getModifiers () & Modifier .STATIC ) != 0 ||
5959 Util .isDefault (method )) {
6060 continue ;
6161 }
62- MethodMetadata metadata = parseAndValidateMetadata (targetType , method );
62+ final MethodMetadata metadata = parseAndValidateMetadata (targetType , method );
6363 checkState (!result .containsKey (metadata .configKey ()), "Overrides unsupported: %s" ,
6464 metadata .configKey ());
6565 result .put (metadata .configKey (), metadata );
@@ -79,7 +79,7 @@ public MethodMetadata parseAndValidateMetadata(Method method) {
7979 * Called indirectly by {@link #parseAndValidateMetadata(Class)}.
8080 */
8181 protected MethodMetadata parseAndValidateMetadata (Class <?> targetType , Method method ) {
82- MethodMetadata data = new MethodMetadata ();
82+ final MethodMetadata data = new MethodMetadata ();
8383 data .targetType (targetType );
8484 data .method (method );
8585 data .returnType (Types .resolve (targetType , targetType , method .getGenericReturnType ()));
@@ -91,20 +91,20 @@ protected MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method me
9191 processAnnotationOnClass (data , targetType );
9292
9393
94- for (Annotation methodAnnotation : method .getAnnotations ()) {
94+ for (final Annotation methodAnnotation : method .getAnnotations ()) {
9595 processAnnotationOnMethod (data , methodAnnotation , method );
9696 }
9797 if (data .isIgnored ()) {
9898 return data ;
9999 }
100100 checkState (data .template ().method () != null ,
101- "Method %s not annotated with HTTP method type (ex. GET, POST)" ,
102- data .configKey ());
103- Class <?>[] parameterTypes = method .getParameterTypes ();
104- Type [] genericParameterTypes = method .getGenericParameterTypes ();
101+ "Method %s not annotated with HTTP method type (ex. GET, POST)%s " ,
102+ data .configKey (), data . warnings () );
103+ final Class <?>[] parameterTypes = method .getParameterTypes ();
104+ final Type [] genericParameterTypes = method .getGenericParameterTypes ();
105105
106- Annotation [][] parameterAnnotations = method .getParameterAnnotations ();
107- int count = parameterAnnotations .length ;
106+ final Annotation [][] parameterAnnotations = method .getParameterAnnotations ();
107+ final int count = parameterAnnotations .length ;
108108 for (int i = 0 ; i < count ; i ++) {
109109 boolean isHttpAnnotation = false ;
110110 if (parameterAnnotations [i ] != null ) {
@@ -120,11 +120,12 @@ protected MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method me
120120 } else if (!isHttpAnnotation && parameterTypes [i ] != Request .Options .class ) {
121121 if (data .isAlreadyProcessed (i )) {
122122 checkState (data .formParams ().isEmpty () || data .bodyIndex () == null ,
123- "Body parameters cannot be used with form parameters." );
123+ "Body parameters cannot be used with form parameters.%s" , data . warnings () );
124124 } else {
125125 checkState (data .formParams ().isEmpty (),
126- "Body parameters cannot be used with form parameters." );
127- checkState (data .bodyIndex () == null , "Method has too many Body parameters: %s" , method );
126+ "Body parameters cannot be used with form parameters.%s" , data .warnings ());
127+ checkState (data .bodyIndex () == null ,
128+ "Method has too many Body parameters: %s%s" , method , data .warnings ());
128129 data .bodyIndex (i );
129130 data .bodyType (Types .resolve (targetType , targetType , genericParameterTypes [i ]));
130131 }
@@ -156,17 +157,17 @@ private static void checkMapKeys(String name, Type genericType) {
156157
157158 // assume our type parameterized
158159 if (ParameterizedType .class .isAssignableFrom (genericType .getClass ())) {
159- Type [] parameterTypes = ((ParameterizedType ) genericType ).getActualTypeArguments ();
160+ final Type [] parameterTypes = ((ParameterizedType ) genericType ).getActualTypeArguments ();
160161 keyClass = (Class <?>) parameterTypes [0 ];
161162 } else if (genericType instanceof Class <?>) {
162163 // raw class, type parameters cannot be inferred directly, but we can scan any extended
163164 // interfaces looking for any explict types
164- Type [] interfaces = ((Class ) genericType ).getGenericInterfaces ();
165+ final Type [] interfaces = ((Class ) genericType ).getGenericInterfaces ();
165166 if (interfaces != null ) {
166- for (Type extended : interfaces ) {
167+ for (final Type extended : interfaces ) {
167168 if (ParameterizedType .class .isAssignableFrom (extended .getClass ())) {
168169 // use the first extended interface we find.
169- Type [] parameterTypes = ((ParameterizedType ) extended ).getActualTypeArguments ();
170+ final Type [] parameterTypes = ((ParameterizedType ) extended ).getActualTypeArguments ();
170171 keyClass = (Class <?>) parameterTypes [0 ];
171172 break ;
172173 }
@@ -214,7 +215,7 @@ protected abstract boolean processAnnotationsOnParameter(MethodMetadata data,
214215 * links a parameter name to its index in the method signature.
215216 */
216217 protected void nameParam (MethodMetadata data , String name , int i ) {
217- Collection <String > names =
218+ final Collection <String > names =
218219 data .indexToName ().containsKey (i ) ? data .indexToName ().get (i ) : new ArrayList <String >();
219220 names .add (name );
220221 data .indexToName ().put (i , names );
@@ -227,20 +228,20 @@ class Default extends DeclarativeContract {
227228
228229 public Default () {
229230 super .registerClassAnnotation (Headers .class , (header , data ) -> {
230- String [] headersOnType = header .value ();
231+ final String [] headersOnType = header .value ();
231232 checkState (headersOnType .length > 0 , "Headers annotation was empty on type %s." ,
232233 data .configKey ());
233- Map <String , Collection <String >> headers = toMap (headersOnType );
234+ final Map <String , Collection <String >> headers = toMap (headersOnType );
234235 headers .putAll (data .template ().headers ());
235236 data .template ().headers (null ); // to clear
236237 data .template ().headers (headers );
237238 });
238239 super .registerMethodAnnotation (RequestLine .class , (ann , data ) -> {
239- String requestLine = ann .value ();
240+ final String requestLine = ann .value ();
240241 checkState (emptyToNull (requestLine ) != null ,
241242 "RequestLine annotation was empty on method %s." , data .configKey ());
242243
243- Matcher requestLineMatcher = REQUEST_LINE_PATTERN .matcher (requestLine );
244+ final Matcher requestLineMatcher = REQUEST_LINE_PATTERN .matcher (requestLine );
244245 if (!requestLineMatcher .find ()) {
245246 throw new IllegalStateException (String .format (
246247 "RequestLine annotation didn't start with an HTTP verb on method %s" ,
@@ -254,7 +255,7 @@ public Default() {
254255 .collectionFormat (ann .collectionFormat ());
255256 });
256257 super .registerMethodAnnotation (Body .class , (ann , data ) -> {
257- String body = ann .value ();
258+ final String body = ann .value ();
258259 checkState (emptyToNull (body ) != null , "Body annotation was empty on method %s." ,
259260 data .configKey ());
260261 if (body .indexOf ('{' ) == -1 ) {
@@ -264,17 +265,17 @@ public Default() {
264265 }
265266 });
266267 super .registerMethodAnnotation (Headers .class , (header , data ) -> {
267- String [] headersOnMethod = header .value ();
268+ final String [] headersOnMethod = header .value ();
268269 checkState (headersOnMethod .length > 0 , "Headers annotation was empty on method %s." ,
269270 data .configKey ());
270271 data .template ().headers (toMap (headersOnMethod ));
271272 });
272273 super .registerParameterAnnotation (Param .class , (paramAnnotation , data , paramIndex ) -> {
273- String name = paramAnnotation .value ();
274+ final String name = paramAnnotation .value ();
274275 checkState (emptyToNull (name ) != null , "Param annotation was empty on param %s." ,
275276 paramIndex );
276277 nameParam (data , name , paramIndex );
277- Class <? extends Param .Expander > expander = paramAnnotation .expander ();
278+ final Class <? extends Param .Expander > expander = paramAnnotation .expander ();
278279 if (expander != Param .ToStringExpander .class ) {
279280 data .indexToExpanderClass ().put (paramIndex , expander );
280281 }
@@ -296,11 +297,11 @@ public Default() {
296297 }
297298
298299 private static Map <String , Collection <String >> toMap (String [] input ) {
299- Map <String , Collection <String >> result =
300+ final Map <String , Collection <String >> result =
300301 new LinkedHashMap <String , Collection <String >>(input .length );
301- for (String header : input ) {
302- int colon = header .indexOf (':' );
303- String name = header .substring (0 , colon );
302+ for (final String header : input ) {
303+ final int colon = header .indexOf (':' );
304+ final String name = header .substring (0 , colon );
304305 if (!result .containsKey (name )) {
305306 result .put (name , new ArrayList <String >(1 ));
306307 }
0 commit comments