Package org.springframework.util
Interface RouteMatcher
- All Known Implementing Classes:
PathPatternRouteMatcher,SimpleRouteMatcher
public interface RouteMatcher
Contract for matching routes to patterns.Equivalent to
PathMatcher, but enables use of parsed representations of routes and patterns for efficiency reasons in scenarios where routes from incoming messages are continuously matched against a large number of message handler patterns.- Since:
- 5.2
- Author:
- Rossen Stoyanchev
- See Also:
PathMatcher
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceRouteMatcher.RouteA parsed representation of a route.
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Stringcombine(String pattern1, String pattern2)Combines two patterns into a single pattern.Comparator<String>getPatternComparator(RouteMatcher.Route route)Given a route, return aComparatorsuitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.booleanisPattern(String route)Whether the givenroutecontains pattern syntax which requires thematch(String, Route)method, or if it is a regular String that could be compared directly to others.booleanmatch(String pattern, RouteMatcher.Route route)Match the given route against the given pattern.Map<String,String>matchAndExtract(String pattern, RouteMatcher.Route route)Match the pattern to the route and extract template variables.RouteMatcher.RouteparseRoute(String routeValue)Return a parsed representation of the given route.
Method Detail
parseRoute
RouteMatcher.Route parseRoute(String routeValue)
Return a parsed representation of the given route.- Parameters:
routeValue- the route to parse- Returns:
- the parsed representation of the route
isPattern
boolean isPattern(String route)
Whether the givenroutecontains pattern syntax which requires thematch(String, Route)method, or if it is a regular String that could be compared directly to others.- Parameters:
route- the route to check- Returns:
trueif the givenrouterepresents a pattern
combine
String combine(String pattern1, String pattern2)
Combines two patterns into a single pattern.- Parameters:
pattern1- the first patternpattern2- the second pattern- Returns:
- the combination of the two patterns
- Throws:
IllegalArgumentException- when the two patterns cannot be combined
match
boolean match(String pattern, RouteMatcher.Route route)
Match the given route against the given pattern.- Parameters:
pattern- the pattern to try to matchroute- the route to test against- Returns:
trueif there is a match,falseotherwise
matchAndExtract
@Nullable Map<String,String> matchAndExtract(String pattern, RouteMatcher.Route route)
Match the pattern to the route and extract template variables.- Parameters:
pattern- the pattern, possibly containing templates variablesroute- the route to extract template variables from- Returns:
- a map with template variables and values
getPatternComparator
Comparator<String> getPatternComparator(RouteMatcher.Route route)
Given a route, return aComparatorsuitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.- Parameters:
route- the full path to use for comparison- Returns:
- a comparator capable of sorting patterns in order of explicitness