类 DestinationPatternsMessageCondition
- java.lang.Object
- org.springframework.messaging.handler.AbstractMessageCondition<DestinationPatternsMessageCondition>
- org.springframework.messaging.handler.DestinationPatternsMessageCondition
public class DestinationPatternsMessageCondition extends AbstractMessageCondition<DestinationPatternsMessageCondition>
MessageCondition
to match the destination header of a Message against one or more patterns through aRouteMatcher
.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
字段概要
字段 修饰符和类型 字段 说明 static String
LOOKUP_DESTINATION_HEADER
The name of the "lookup destination" header.
构造器概要
构造器 构造器 说明 DestinationPatternsMessageCondition(String... patterns)
Constructor with patterns only.DestinationPatternsMessageCondition(String[] patterns, PathMatcher matcher)
Constructor with patterns and aPathMatcher
instance.DestinationPatternsMessageCondition(String[] patterns, RouteMatcher routeMatcher)
Constructor with patterns and aRouteMatcher
instance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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" usingPathMatcher.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. destination patterns), nevernull
.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 viaPathMatcher.getPatternComparator(String)
.Set<String>
getPatterns()
protected String
getToStringInfix()
The notation to use when printing discrete items of content.从类继承的方法 org.springframework.messaging.handler.AbstractMessageCondition
equals, hashCode, toString
字段详细资料
LOOKUP_DESTINATION_HEADER
public static final String LOOKUP_DESTINATION_HEADER
The name of the "lookup destination" header.- 另请参阅:
- 常量字段值
构造器详细资料
DestinationPatternsMessageCondition
public DestinationPatternsMessageCondition(String... patterns)
Constructor with patterns only. Creates and uses an instance ofAntPathMatcher
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 match
DestinationPatternsMessageCondition
public DestinationPatternsMessageCondition(String[] patterns, @Nullable PathMatcher matcher)
Constructor with patterns and aPathMatcher
instance.- 参数:
patterns
- the URL patterns to match to, or if 0 then always matchmatcher
- thePathMatcher
to use
DestinationPatternsMessageCondition
public DestinationPatternsMessageCondition(String[] patterns, RouteMatcher routeMatcher)
Constructor with patterns and aRouteMatcher
instance.- 参数:
patterns
- the URL patterns to match to, or if 0 then always matchrouteMatcher
- theRouteMatcher
to use- 从以下版本开始:
- 5.2
方法详细资料
getPatterns
public Set<String> getPatterns()
getContent
protected Collection<String> getContent()
从类复制的说明:AbstractMessageCondition
Return the collection of objects the message condition is composed of (e.g. destination patterns), nevernull
.
getToStringInfix
protected String getToStringInfix()
从类复制的说明:AbstractMessageCondition
The notation to use when printing discrete items of content. For example " || " for URL patterns or " && " for param expressions.
combine
public 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)
. - If only one instance has patterns, use them.
- If neither instance has patterns, use an empty String (i.e. "").
- 参数:
other
- the condition to combine with- 返回:
- the resulting message condition
- If there are patterns in both instances, combine the patterns in "this" with the patterns in "other" using
getMatchingCondition
@Nullable public 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 viaPathMatcher.getPatternComparator(String)
.- 参数:
message
- the message to match to- 返回:
- the same instance if the condition contains no patterns; or a new condition with sorted matching patterns; or
null
either if a destination can not be extracted or there is no match
compareTo
public int compareTo(DestinationPatternsMessageCondition other, Message<?> message)
Compare the two conditions based on the destination patterns they contain. Patterns are compared one at a time, from top to bottom viaPathMatcher.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.