polishing
This commit is contained in:
parent
0195b0da3c
commit
4c73a29f99
|
|
@ -50,6 +50,7 @@ public abstract class AnnotationUtils {
|
||||||
/** The attribute name for annotations with a single element */
|
/** The attribute name for annotations with a single element */
|
||||||
static final String VALUE = "value";
|
static final String VALUE = "value";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all {@link Annotation Annotations} from the supplied {@link Method}.
|
* Get all {@link Annotation Annotations} from the supplied {@link Method}.
|
||||||
* <p>Correctly handles bridge {@link Method Methods} generated by the compiler.
|
* <p>Correctly handles bridge {@link Method Methods} generated by the compiler.
|
||||||
|
|
@ -135,14 +136,16 @@ public abstract class AnnotationUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a single {@link Annotation} of <code>annotationType</code> from the supplied {@link Class}, traversing its
|
* Find a single {@link Annotation} of <code>annotationType</code> from the supplied {@link Class},
|
||||||
* interfaces and super classes if no annotation can be found on the given class itself. <p>This method explicitly
|
* traversing its interfaces and super classes if no annotation can be found on the given class itself.
|
||||||
* handles class-level annotations which are not declared as {@link java.lang.annotation.Inherited inherited} <i>as
|
* <p>This method explicitly handles class-level annotations which are not declared as
|
||||||
* well as annotations on interfaces</i>. <p>The algorithm operates as follows: Searches for an annotation on the given
|
* {@link Inherited inherited} <i>as well as annotations on interfaces</i>.
|
||||||
* class and returns it if found. Else searches all interfaces that the given class declares, returning the annotation
|
* <p>The algorithm operates as follows: Searches for an annotation on the given class and returns
|
||||||
* from the first matching candidate, if any. Else proceeds with introspection of the superclass of the given class,
|
* it if found. Else searches all interfaces that the given class declares, returning the annotation
|
||||||
* checking the superclass itself; if no annotation found there, proceeds with the interfaces that the superclass
|
* from the first matching candidate, if any. Else proceeds with introspection of the superclass
|
||||||
* declares. Recursing up through the entire superclass hierarchy if no match is found.
|
* of the given class, checking the superclass itself; if no annotation found there, proceeds
|
||||||
|
* with the interfaces that the superclass declares. Recursing up through the entire superclass
|
||||||
|
* hierarchy if no match is found.
|
||||||
* @param clazz the class to look for annotations on
|
* @param clazz the class to look for annotations on
|
||||||
* @param annotationType the annotation class to look for
|
* @param annotationType the annotation class to look for
|
||||||
* @return the annotation found, or <code>null</code> if none found
|
* @return the annotation found, or <code>null</code> if none found
|
||||||
|
|
@ -175,18 +178,21 @@ public abstract class AnnotationUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the first {@link Class} in the inheritance hierarchy of the specified <code>clazz</code> (including the
|
* Find the first {@link Class} in the inheritance hierarchy of the specified <code>clazz</code>
|
||||||
* specified <code>clazz</code> itself) which declares an annotation for the specified <code>annotationType</code>, or
|
* (including the specified <code>clazz</code> itself) which declares an annotation for the
|
||||||
* <code>null</code> if not found. If the supplied <code>clazz</code> is <code>null</code>, <code>null</code> will be
|
* specified <code>annotationType</code>, or <code>null</code> if not found. If the supplied
|
||||||
* returned. <p>If the supplied <code>clazz</code> is an interface, only the interface itself will be checked; the
|
* <code>clazz</code> is <code>null</code>, <code>null</code> will be returned.
|
||||||
* inheritance hierarchy for interfaces will not be traversed. <p>The standard {@link Class} API does not provide a
|
* <p>If the supplied <code>clazz</code> is an interface, only the interface itself will be checked;
|
||||||
* mechanism for determining which class in an inheritance hierarchy actually declares an {@link Annotation}, so we
|
* the inheritance hierarchy for interfaces will not be traversed.
|
||||||
* need to handle this explicitly.
|
* <p>The standard {@link Class} API does not provide a mechanism for determining which class
|
||||||
|
* in an inheritance hierarchy actually declares an {@link Annotation}, so we need to handle
|
||||||
|
* this explicitly.
|
||||||
* @param annotationType the Class object corresponding to the annotation type
|
* @param annotationType the Class object corresponding to the annotation type
|
||||||
* @param clazz the Class object corresponding to the class on which to check for the annotation, or
|
* @param clazz the Class object corresponding to the class on which to check for the annotation,
|
||||||
* <code>null</code>.
|
* or <code>null</code>
|
||||||
* @return the first {@link Class} in the inheritance hierarchy of the specified <code>clazz</code> which
|
* @return the first {@link Class} in the inheritance hierarchy of the specified <code>clazz</code>
|
||||||
* declares an annotation for the specified <code>annotationType</code>, or <code>null</code> if not found.
|
* which declares an annotation for the specified <code>annotationType</code>, or <code>null</code>
|
||||||
|
* if not found
|
||||||
* @see Class#isAnnotationPresent(Class)
|
* @see Class#isAnnotationPresent(Class)
|
||||||
* @see Class#getDeclaredAnnotations()
|
* @see Class#getDeclaredAnnotations()
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1093,6 +1093,7 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of {@link RequestMappingInfo} that holds request-specific data.
|
* Subclass of {@link RequestMappingInfo} that holds request-specific data.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1119,22 +1120,21 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
|
||||||
public String bestMatchedPattern() {
|
public String bestMatchedPattern() {
|
||||||
return (!this.matchedPatterns.isEmpty() ? this.matchedPatterns.get(0) : null);
|
return (!this.matchedPatterns.isEmpty() ? this.matchedPatterns.get(0) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comparator capable of sorting {@link RequestSpecificMappingInfo}s (RHIs) so that sorting a list with this comparator will
|
* Comparator capable of sorting {@link RequestSpecificMappingInfo}s (RHIs) so that
|
||||||
* result in:
|
* sorting a list with this comparator will result in:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>RHIs with {@linkplain org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.RequestSpecificMappingInfo#matchedPatterns better matched paths} take prescedence
|
* <li>RHIs with {@linkplain AnnotationMethodHandlerAdapter.RequestSpecificMappingInfo#matchedPatterns better matched paths}
|
||||||
* over those with a weaker match (as expressed by the {@linkplain PathMatcher#getPatternComparator(String) path
|
* take prescedence over those with a weaker match (as expressed by the {@linkplain PathMatcher#getPatternComparator(String)
|
||||||
* pattern comparator}.) Typically, this means that patterns without wild cards and uri templates will be ordered
|
* path pattern comparator}.) Typically, this means that patterns without wild cards and uri templates
|
||||||
* before those without.</li>
|
* will be ordered before those without.</li>
|
||||||
* <li>RHIs with one single {@linkplain RequestMappingInfo#methods request method} will be
|
* <li>RHIs with one single {@linkplain RequestMappingInfo#methods request method} will be
|
||||||
* ordered before those without a method, or with more than one method.</li>
|
* ordered before those without a method, or with more than one method.</li>
|
||||||
* <li>RHIs with more {@linkplain RequestMappingInfo#params request parameters} will be ordered before those with
|
* <li>RHIs with more {@linkplain RequestMappingInfo#params request parameters} will be ordered
|
||||||
* less parameters</li>
|
* before those with less parameters</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*/
|
*/
|
||||||
static class RequestSpecificMappingInfoComparator implements Comparator<RequestSpecificMappingInfo> {
|
static class RequestSpecificMappingInfoComparator implements Comparator<RequestSpecificMappingInfo> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue