Top Description Inners Methods
org.springframework.util

public Interface RouteMatcher

Known Direct Implementers
org.springframework.util.SimpleRouteMatcher
Imports
java.util.Comparator, .Map, org.springframework.lang.Nullable

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.

Author
Rossen Stoyanchev
Since
5.2
See Also
PathMatcher

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
RouteMatcher.Route

A parsed representation of a route.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the combination of the two patterns
combine
(String
the first pattern
pattern1
,
String
the second pattern
pattern2
)

Combines two patterns into a single pattern.

public Comparator<String>

Returns:

a comparator capable of sorting patterns in order of explicitness
getPatternComparator
(RouteMatcher.Route
the full path to use for comparison
route
)

Given a route, return a Comparator suitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.

public boolean

Returns:

true if the given route represents a pattern
isPattern
(String
the route to check
route
)

Whether the given route contains pattern syntax which requires the match(String, Route) method, or if it is a regular String that could be compared directly to others.

public boolean

Returns:

true if there is a match, false otherwise
match
(String
the pattern to try to match
pattern
,
RouteMatcher.Route
the route to test against
route
)

Match the given route against the given pattern.

public Map<String, String>

Returns:

a map with template variables and values
matchAndExtract
(String
the pattern, possibly containing templates variables
pattern
,
RouteMatcher.Route
the route to extract template variables from
route
)

Match the pattern to the route and extract template variables.

public RouteMatcher.Route

Returns:

the parsed representation of the route
parseRoute
(String
the route to parse
routeValue
)

Return a parsed representation of the given route.

Method Detail

combineback to summary
public String combine(String pattern1, String pattern2)

Combines two patterns into a single pattern.

Parameters
pattern1:String

the first pattern

pattern2:String

the second pattern

Returns:String

the combination of the two patterns

Exceptions
IllegalArgumentException:
when the two patterns cannot be combined
getPatternComparatorback to summary
public Comparator<String> getPatternComparator(RouteMatcher.Route route)

Given a route, return a Comparator suitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.

Parameters
route:RouteMatcher.Route

the full path to use for comparison

Returns:Comparator<String>

a comparator capable of sorting patterns in order of explicitness

isPatternback to summary
public boolean isPattern(String route)

Whether the given route contains pattern syntax which requires the match(String, Route) method, or if it is a regular String that could be compared directly to others.

Parameters
route:String

the route to check

Returns:boolean

true if the given route represents a pattern

matchback to summary
public boolean match(String pattern, RouteMatcher.Route route)

Match the given route against the given pattern.

Parameters
pattern:String

the pattern to try to match

route:RouteMatcher.Route

the route to test against

Returns:boolean

true if there is a match, false otherwise

matchAndExtractback to summary
public Map<String, String> matchAndExtract(String pattern, RouteMatcher.Route route)

Match the pattern to the route and extract template variables.

Parameters
pattern:String

the pattern, possibly containing templates variables

route:RouteMatcher.Route

the route to extract template variables from

Returns:Map<String, String>

a map with template variables and values

Annotations
@Nullable
parseRouteback to summary
public RouteMatcher.Route parseRoute(String routeValue)

Return a parsed representation of the given route.

Parameters
routeValue:String

the route to parse

Returns:RouteMatcher.Route

the parsed representation of the route

org.springframework.util back to summary

public Interface RouteMatcher.Route

Known Direct Implementers
org.springframework.util.SimpleRouteMatcher.DefaultRoute

A parsed representation of a route.

Method Summary

Modifier and TypeMethod and Description
public String
value()

The original route value.

Method Detail

valueback to summary
public String value()

The original route value.