Override toString() in all RequestMatcher

It makes it easier to debug having custom
toString().

Fixes: gh-5446
This commit is contained in:
Rob Winch
2018-06-15 11:27:28 -05:00
parent 71986e5f42
commit c3177a84a3
7 changed files with 83 additions and 0 deletions

View File

@@ -123,6 +123,24 @@ public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtrac
return this.servletPath;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Mvc [pattern='").append(this.pattern).append("'");
if (this.servletPath != null) {
sb.append(", servletPath='").append(this.servletPath).append("'");
}
if (this.method != null) {
sb.append(", ").append(this.method);
}
sb.append("]");
return sb.toString();
}
private class DefaultMatcher implements RequestMatcher, RequestVariablesExtractor {
private final UrlPathHelper pathHelper = new UrlPathHelper();

View File

@@ -44,6 +44,11 @@ public final class AnyRequestMatcher implements RequestMatcher {
return 1;
}
@Override
public String toString() {
return "any request";
}
private AnyRequestMatcher() {
}
}

View File

@@ -65,4 +65,11 @@ public class ELRequestMatcher implements RequestMatcher {
return new StandardEvaluationContext(new ELRequestMatcherContext(request));
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("EL [el=\"").append(this.expression.getExpressionString()).append("\"");
sb.append("]");
return sb.toString();
}
}

View File

@@ -130,4 +130,18 @@ public final class RegexRequestMatcher implements RequestMatcher {
return null;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Regex [pattern='").append(this.pattern).append("'");
if (this.httpMethod != null) {
sb.append(", ").append(this.httpMethod);
}
sb.append("]");
return sb.toString();
}
}