public class DestinationPatternsMessageCondition extends AbstractMessageCondition<DestinationPatternsMessageCondition>
MessageCondition
for matching the destination of a Message against one or
more destination patterns using a PathMatcher
.Modifier and Type | Field and Description |
---|---|
static String |
LOOKUP_DESTINATION_HEADER |
Constructor and Description |
---|
DestinationPatternsMessageCondition(String... patterns)
Creates a new instance with the given destination patterns.
|
DestinationPatternsMessageCondition(String[] patterns,
PathMatcher pathMatcher)
Additional constructor with flags for using suffix pattern (.*) and trailing slash matches.
|
Modifier and Type | Method and Description |
---|---|
DestinationPatternsMessageCondition |
combine(DestinationPatternsMessageCondition other)
Returns a new instance with URL patterns from the current instance ("this") and
the "other" instance as follows:
If there are patterns in both instances, combine the patterns in "this" with
the patterns in "other" using
PathMatcher.combine(String, String) . |
int |
compareTo(DestinationPatternsMessageCondition other,
Message<?> message)
Compare the two conditions based on the destination patterns they contain.
|
protected Collection<String> |
getContent() |
DestinationPatternsMessageCondition |
getMatchingCondition(Message<?> message)
Check if any of the patterns match the given Message destination and return an instance
that is guaranteed to contain matching patterns, sorted via
PathMatcher.getPatternComparator(String) . |
Set<String> |
getPatterns() |
protected String |
getToStringInfix()
The notation to use when printing discrete items of content.
|
equals, hashCode, toString
public static final String LOOKUP_DESTINATION_HEADER
public DestinationPatternsMessageCondition(String... patterns)
patterns
- 0 or more URL patterns; if 0 the condition will match to every request.public DestinationPatternsMessageCondition(String[] patterns, PathMatcher pathMatcher)
patterns
- the URL patterns to use; if 0, the condition will match to every request.pathMatcher
- the PathMatcher to useprotected Collection<String> getContent()
getContent
in class AbstractMessageCondition<DestinationPatternsMessageCondition>
null
protected String getToStringInfix()
AbstractMessageCondition
getToStringInfix
in class AbstractMessageCondition<DestinationPatternsMessageCondition>
public DestinationPatternsMessageCondition combine(DestinationPatternsMessageCondition other)
PathMatcher.combine(String, String)
.
other
- the condition to combine withpublic DestinationPatternsMessageCondition getMatchingCondition(Message<?> message)
PathMatcher.getPatternComparator(String)
.message
- the message to match tonull
either if a destination can not be extracted or there is no matchpublic int compareTo(DestinationPatternsMessageCondition other, Message<?> message)
PathMatcher.getPatternComparator(String)
.
If all compared patterns match equally, but one instance has more patterns,
it is considered a closer match.
It is assumed that both instances have been obtained via
getMatchingCondition(Message)
to ensure they
contain only patterns that match the request and are sorted with
the best matches on top.