接口 RouteMatcher
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.- 从以下版本开始:
- 5.2
- 作者:
- Rossen Stoyanchev
- 另请参阅:
PathMatcher
嵌套类概要
嵌套类 修饰符和类型 接口 说明 static interface
RouteMatcher.Route
A parsed representation of a route.
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 String
combine(String pattern1, String pattern2)
Combines two patterns into a single pattern.Comparator<String>
getPatternComparator(RouteMatcher.Route route)
Given a route, return aComparator
suitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.boolean
isPattern(String route)
Whether the givenroute
contains pattern syntax which requires thematch(String, Route)
method, or if it is a regular String that could be compared directly to others.boolean
match(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.Route
parseRoute(String routeValue)
Return a parsed representation of the given route.
方法详细资料
parseRoute
RouteMatcher.Route parseRoute(String routeValue)
Return a parsed representation of the given route.- 参数:
routeValue
- the route to parse- 返回:
- the parsed representation of the route
isPattern
boolean isPattern(String route)
Whether the givenroute
contains pattern syntax which requires thematch(String, Route)
method, or if it is a regular String that could be compared directly to others.- 参数:
route
- the route to check- 返回:
true
if the givenroute
represents a pattern
combine
String combine(String pattern1, String pattern2)
Combines two patterns into a single pattern.- 参数:
pattern1
- the first patternpattern2
- the second pattern- 返回:
- the combination of the two patterns
- 抛出:
IllegalArgumentException
- when the two patterns cannot be combined
match
boolean match(String pattern, RouteMatcher.Route route)
Match the given route against the given pattern.- 参数:
pattern
- the pattern to try to matchroute
- the route to test against- 返回:
true
if there is a match,false
otherwise
matchAndExtract
@Nullable Map<String,String> matchAndExtract(String pattern, RouteMatcher.Route route)
Match the pattern to the route and extract template variables.- 参数:
pattern
- the pattern, possibly containing templates variablesroute
- the route to extract template variables from- 返回:
- a map with template variables and values
getPatternComparator
Comparator<String> getPatternComparator(RouteMatcher.Route route)
Given a route, return aComparator
suitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.- 参数:
route
- the full path to use for comparison- 返回:
- a comparator capable of sorting patterns in order of explicitness