diff --git a/org.springframework.core/src/main/java/org/springframework/util/AntPathMatcher.java b/org.springframework.core/src/main/java/org/springframework/util/AntPathMatcher.java index 01994949d5d..9602d7cc1b0 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/org.springframework.core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -16,6 +16,7 @@ package org.springframework.util; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.Map; @@ -52,6 +53,7 @@ import java.util.Map; * @author Alef Arendsen * @author Juergen Hoeller * @author Rob Harrop + * @author Arjen Poutsma * @since 16.07.2003 */ public class AntPathMatcher implements PathMatcher { @@ -288,4 +290,73 @@ public class AntPathMatcher implements PathMatcher { return variables; } + /** + * Given a full path, returns a {@link Comparator} suitable for sorting patterns in order of explicitness. + * + *
The returned Comparator will {@linkplain java.util.Collections#sort(java.util.List,
+ * java.util.Comparator) sort} a list so that more specific patterns (without uri templates or wild cards) come before
+ * generic patterns. So given a list with the following patterns:
+ *
/hotels/new/hotels/{hotel}/hotels/*String-based path matching.
- *
+ *
* Used by {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver},
* {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping},
* {@link org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver},
@@ -102,4 +103,16 @@ public interface PathMatcher {
* @return a map, containing variable names as keys; variables values as values
*/
Map The full algorithm used depends on the underlying implementation, but generally, the returned
+ * Comparator will {@linkplain java.util.Collections#sort(java.util.List, java.util.Comparator) sort} a
+ * list so that more specific patterns come before generic patterns.
+ *
+ * @param path the full path to use for comparison
+ * @return a comparator capable of sorting patterns in order of explicitness
+ */
+ Comparator