36
36
* Discovers {@linkplain ExceptionHandler @ExceptionHandler} methods in a given class,
37
37
* including all of its superclasses, and helps to resolve a given {@link Exception}
38
38
* to the exception types supported by a given {@link Method}.
39
- *
39
+ *
40
40
* @author Rossen Stoyanchev
41
41
* @since 3.1
42
42
*/
@@ -79,8 +79,8 @@ public ExceptionHandlerMethodResolver(Class<?> handlerType) {
79
79
80
80
81
81
/**
82
- * Extract exception mappings from the {@code @ExceptionHandler} annotation
83
- * first and as a fall-back from the method signature.
82
+ * Extract exception mappings from the {@code @ExceptionHandler} annotation first,
83
+ * and then as a fallback from the method signature itself .
84
84
*/
85
85
@ SuppressWarnings ("unchecked" )
86
86
private List <Class <? extends Throwable >> detectExceptionMappings (Method method ) {
@@ -115,7 +115,7 @@ private void addExceptionMapping(Class<? extends Throwable> exceptionType, Metho
115
115
* Whether the contained type has any exception mappings.
116
116
*/
117
117
public boolean hasExceptionMappings () {
118
- return ( this .mappedMethods .size () > 0 );
118
+ return ! this .mappedMethods .isEmpty ( );
119
119
}
120
120
121
121
/**
@@ -140,11 +140,11 @@ public Method resolveMethodByExceptionType(Class<? extends Exception> exceptionT
140
140
method = getMappedMethod (exceptionType );
141
141
this .exceptionLookupCache .put (exceptionType , (method != null ? method : NO_METHOD_FOUND ));
142
142
}
143
- return method != NO_METHOD_FOUND ? method : null ;
143
+ return ( method != NO_METHOD_FOUND ? method : null ) ;
144
144
}
145
145
146
146
/**
147
- * Return the method mapped to the given exception type or {@code null}.
147
+ * Return the {@link Method} mapped to the given exception type, or {@code null} if none .
148
148
*/
149
149
private Method getMappedMethod (Class <? extends Exception > exceptionType ) {
150
150
List <Class <? extends Throwable >> matches = new ArrayList <Class <? extends Throwable >>();
0 commit comments