org.springframework.web.servlet.mvc.annotation
Class AnnotationMethodHandlerAdapter.RequestSpecificMappingInfoComparator
java.lang.Object
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.RequestSpecificMappingInfoComparator
- All Implemented Interfaces:
- java.util.Comparator<AnnotationMethodHandlerAdapter.RequestSpecificMappingInfo>
- Enclosing class:
- AnnotationMethodHandlerAdapter
static class AnnotationMethodHandlerAdapter.RequestSpecificMappingInfoComparator
- extends java.lang.Object
- implements java.util.Comparator<AnnotationMethodHandlerAdapter.RequestSpecificMappingInfo>
Comparator capable of sorting AnnotationMethodHandlerAdapter.RequestSpecificMappingInfo
s (RHIs) so that
sorting a list with this comparator will result in:
- RHIs with better matched paths
take prescedence over those with a weaker match (as expressed by the path pattern comparator.) Typically, this means that patterns without wild cards and uri templates
will be ordered before those without.
- RHIs with one single request method will be
ordered before those without a method, or with more than one method.
- RHIs with more request parameters will be ordered
before those with less parameters
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
pathComparator
private final java.util.Comparator<java.lang.String> pathComparator
request
private final ServerHttpRequest request
AnnotationMethodHandlerAdapter.RequestSpecificMappingInfoComparator
AnnotationMethodHandlerAdapter.RequestSpecificMappingInfoComparator(java.util.Comparator<java.lang.String> pathComparator,
HttpServletRequest request)
compare
public int compare(AnnotationMethodHandlerAdapter.RequestSpecificMappingInfo info1,
AnnotationMethodHandlerAdapter.RequestSpecificMappingInfo info2)
- Specified by:
compare
in interface java.util.Comparator<AnnotationMethodHandlerAdapter.RequestSpecificMappingInfo>
compareAcceptHeaders
private int compareAcceptHeaders(AnnotationMethodHandlerAdapter.RequestMappingInfo info1,
AnnotationMethodHandlerAdapter.RequestMappingInfo info2)
indexOfIncluded
private int indexOfIncluded(java.util.List<MediaType> infoAccepts,
MediaType requestAccept)
getAcceptHeaderValue
private java.util.List<MediaType> getAcceptHeaderValue(AnnotationMethodHandlerAdapter.RequestMappingInfo info)