Polishing

This commit is contained in:
Juergen Hoeller
2014-11-01 13:00:54 +01:00
parent fde0713a94
commit f691618967
30 changed files with 151 additions and 163 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,8 +38,7 @@ import org.springframework.util.StringUtils;
* @author Rossen Stoyanchev
* @since 4.0
*/
public final class DestinationPatternsMessageCondition
extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
public class DestinationPatternsMessageCondition extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
public static final String LOOKUP_DESTINATION_HEADER = "lookupDestination";
@@ -59,22 +58,22 @@ public final class DestinationPatternsMessageCondition
}
/**
* Additional constructor with flags for using suffix pattern (.*) and
* trailing slash matches.
* Additional constructor with flags for using suffix pattern (.*) and trailing slash matches.
* @param patterns the URL patterns to use; if 0, the condition will match to every request.
* @param pathMatcher for path matching with patterns
* @param pathMatcher the PathMatcher to use
*/
public DestinationPatternsMessageCondition(String[] patterns,PathMatcher pathMatcher) {
public DestinationPatternsMessageCondition(String[] patterns, PathMatcher pathMatcher) {
this(asList(patterns), pathMatcher);
}
private DestinationPatternsMessageCondition(Collection<String> patterns, PathMatcher pathMatcher) {
this.patterns = Collections.unmodifiableSet(prependLeadingSlash(patterns));
this.pathMatcher = (pathMatcher != null) ? pathMatcher : new AntPathMatcher();
this.pathMatcher = (pathMatcher != null ? pathMatcher : new AntPathMatcher());
}
private static List<String> asList(String... patterns) {
return patterns != null ? Arrays.asList(patterns) : Collections.<String>emptyList();
return (patterns != null ? Arrays.asList(patterns) : Collections.<String>emptyList());
}
private static Set<String> prependLeadingSlash(Collection<String> patterns) {
@@ -91,6 +90,7 @@ public final class DestinationPatternsMessageCondition
return result;
}
public Set<String> getPatterns() {
return this.patterns;
}
@@ -105,14 +105,15 @@ public final class DestinationPatternsMessageCondition
return " || ";
}
/**
* Returns a new instance with URL patterns from the current instance ("this") and
* the "other" instance as follows:
* <ul>
* <li>If there are patterns in both instances, combine the patterns in "this" with
* the patterns in "other" using {@link org.springframework.util.PathMatcher#combine(String, String)}.
* <li>If only one instance has patterns, use them.
* <li>If neither instance has patterns, use an empty String (i.e. "").
* <li>If there are patterns in both instances, combine the patterns in "this" with
* the patterns in "other" using {@link org.springframework.util.PathMatcher#combine(String, String)}.
* <li>If only one instance has patterns, use them.
* <li>If neither instance has patterns, use an empty String (i.e. "").
* </ul>
*/
@Override