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 java.lang.String |
LOOKUP_DESTINATION_HEADER |
Constructor and Description |
---|
DestinationPatternsMessageCondition(java.lang.String... patterns)
Creates a new instance with the given destination patterns.
|
DestinationPatternsMessageCondition(java.lang.String[] patterns,
PathMatcher pathMatcher)
Alternative constructor accepting a custom PathMatcher.
|
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 java.util.Collection<java.lang.String> |
getContent()
Return the collection of objects the message condition is composed of
(e.g.
|
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) . |
java.util.Set<java.lang.String> |
getPatterns() |
protected java.lang.String |
getToStringInfix()
The notation to use when printing discrete items of content.
|
equals, hashCode, toString
public static final java.lang.String LOOKUP_DESTINATION_HEADER
public DestinationPatternsMessageCondition(java.lang.String... patterns)
patterns
- 0 or more URL patterns; if 0 the condition will match to every request.public DestinationPatternsMessageCondition(java.lang.String[] patterns, @Nullable PathMatcher pathMatcher)
patterns
- the URL patterns to use; if 0, the condition will match to every request.pathMatcher
- the PathMatcher to usepublic java.util.Set<java.lang.String> getPatterns()
protected java.util.Collection<java.lang.String> getContent()
AbstractMessageCondition
null
.getContent
in class AbstractMessageCondition<DestinationPatternsMessageCondition>
protected java.lang.String getToStringInfix()
AbstractMessageCondition
getToStringInfix
in class AbstractMessageCondition<DestinationPatternsMessageCondition>
public DestinationPatternsMessageCondition combine(DestinationPatternsMessageCondition other)
PathMatcher.combine(String, String)
.
other
- the condition to combine with@Nullable public 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.