Polishing
This commit is contained in:
@@ -22,8 +22,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.PathMatcher;
|
||||
|
||||
import static org.springframework.util.StringUtils.*;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents a parsed path pattern. Includes a chain of path elements
|
||||
@@ -154,9 +153,9 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
*/
|
||||
public boolean matches(String path) {
|
||||
if (this.head == null) {
|
||||
return !hasLength(path);
|
||||
return !StringUtils.hasLength(path);
|
||||
}
|
||||
else if (!hasLength(path)) {
|
||||
else if (!StringUtils.hasLength(path)) {
|
||||
if (this.head instanceof WildcardTheRestPathElement || this.head instanceof CaptureTheRestPathElement) {
|
||||
path = ""; // Will allow CaptureTheRest to bind the variable to empty
|
||||
}
|
||||
@@ -179,7 +178,7 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
if (this.head == null) {
|
||||
return new PathRemainingMatchInfo(path);
|
||||
}
|
||||
else if (!hasLength(path)) {
|
||||
else if (!StringUtils.hasLength(path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -208,9 +207,9 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
*/
|
||||
public boolean matchStart(String path) {
|
||||
if (this.head == null) {
|
||||
return !hasLength(path);
|
||||
return !StringUtils.hasLength(path);
|
||||
}
|
||||
else if (!hasLength(path)) {
|
||||
else if (!StringUtils.hasLength(path)) {
|
||||
return true;
|
||||
}
|
||||
MatchingContext matchingContext = new MatchingContext(path, false);
|
||||
@@ -228,13 +227,11 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
if (this.head != null && this.head.matches(0, matchingContext)) {
|
||||
return matchingContext.getExtractedVariables();
|
||||
}
|
||||
else if (!StringUtils.hasLength(path)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
else {
|
||||
if (!hasLength(path)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Pattern \"" + this + "\" is not a match for \"" + path + "\"");
|
||||
}
|
||||
throw new IllegalStateException("Pattern \"" + this + "\" is not a match for \"" + path + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,15 +397,15 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
*/
|
||||
public String combine(String pattern2string) {
|
||||
// If one of them is empty the result is the other. If both empty the result is ""
|
||||
if (!hasLength(this.patternString)) {
|
||||
if (!hasLength(pattern2string)) {
|
||||
if (!StringUtils.hasLength(this.patternString)) {
|
||||
if (!StringUtils.hasLength(pattern2string)) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
return pattern2string;
|
||||
}
|
||||
}
|
||||
else if (!hasLength(pattern2string)) {
|
||||
else if (!StringUtils.hasLength(pattern2string)) {
|
||||
return this.patternString;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,14 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||
|
||||
/**
|
||||
* A regex path element. Used to represent any complicated element of the path.
|
||||
* For example in '<tt>/foo/*_*/*_{foobar}</tt>' both <tt>*_*</tt> and <tt>*_{foobar}</tt>
|
||||
* are {@link RegexPathElement} path elements. Derived from the general {@link AntPathMatcher} approach.
|
||||
* are {@link RegexPathElement} path elements. Derived from the general
|
||||
* {@link org.springframework.util.AntPathMatcher} approach.
|
||||
*
|
||||
* @author Andy Clement
|
||||
* @since 5.0
|
||||
|
||||
@@ -48,7 +48,7 @@ class SeparatorPathElement extends PathElement {
|
||||
matched = true;
|
||||
}
|
||||
else {
|
||||
matched = ((candidateIndex + 1) == matchingContext.candidateLength);
|
||||
matched = (candidateIndex + 1 == matchingContext.candidateLength);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user