public class DestinationPatternsMessageCondition extends AbstractMessageCondition<DestinationPatternsMessageCondition>
MessageCondition
to match the destination header of a Message
against one or more patterns through a RouteMatcher
.Modifier and Type | Field and Description |
---|---|
static String |
LOOKUP_DESTINATION_HEADER
The name of the "lookup destination" header.
|
Constructor and Description |
---|
DestinationPatternsMessageCondition(String... patterns)
Constructor with patterns only.
|
DestinationPatternsMessageCondition(String[] patterns,
PathMatcher matcher)
Constructor with patterns and a
PathMatcher instance. |
DestinationPatternsMessageCondition(String[] patterns,
RouteMatcher routeMatcher)
Constructor with patterns and a
RouteMatcher instance. |
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()
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) . |
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)
AntPathMatcher
with default settings.
Non-empty patterns that don't start with "/" are prepended with "/".
patterns
- the URL patterns to match to, or if 0 then always matchpublic DestinationPatternsMessageCondition(String[] patterns, @Nullable PathMatcher matcher)
PathMatcher
instance.patterns
- the URL patterns to match to, or if 0 then always matchmatcher
- the PathMatcher
to usepublic DestinationPatternsMessageCondition(String[] patterns, RouteMatcher routeMatcher)
RouteMatcher
instance.patterns
- the URL patterns to match to, or if 0 then always matchrouteMatcher
- the RouteMatcher
to useprotected Collection<String> getContent()
AbstractMessageCondition
null
.getContent
in class AbstractMessageCondition<DestinationPatternsMessageCondition>
protected 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.