Polishes how error messages are displayed

This commit is contained in:
Lukasz Lenart
2014-11-12 09:59:31 +01:00
parent eeab265282
commit 266f83f15c
5 changed files with 17 additions and 17 deletions
@@ -430,14 +430,14 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
if (result.isAccepted()) {
return true;
}
notifyDeveloper("Parameter [#0] didn't match accepted pattern [#1]!", paramName, String.valueOf(result.getAcceptedPattern()));
notifyDeveloper("Parameter [#0] didn't match accepted pattern [#1]!", paramName, result.getAcceptedPattern());
return false;
}
protected boolean isExcluded(String paramName) {
ExcludedPatternsChecker.IsExcluded result = excludedPatterns.isExcluded(paramName);
if (result.isExcluded()) {
notifyDeveloper("Parameter [#0] matches excluded pattern [#1]!", paramName, String.valueOf(result.getExcludedPattern()));
notifyDeveloper("Parameter [#0] matches excluded pattern [#1]!", paramName, result.getExcludedPattern());
return true;
}
return false;
@@ -47,17 +47,17 @@ public interface AcceptedPatternsChecker {
public final static class IsAccepted {
private final boolean accepted;
private final Pattern acceptedPattern;
private final String acceptedPattern;
public static IsAccepted yes(Pattern acceptedPattern) {
public static IsAccepted yes(String acceptedPattern) {
return new IsAccepted(true, acceptedPattern);
}
public static IsAccepted no() {
return new IsAccepted(false, null);
public static IsAccepted no(String acceptedPatterns) {
return new IsAccepted(false, acceptedPatterns);
}
private IsAccepted(boolean accepted, Pattern acceptedPattern) {
private IsAccepted(boolean accepted, String acceptedPattern) {
this.accepted = accepted;
this.acceptedPattern = acceptedPattern;
}
@@ -66,7 +66,7 @@ public interface AcceptedPatternsChecker {
return accepted;
}
public Pattern getAcceptedPattern() {
public String getAcceptedPattern() {
return acceptedPattern;
}
@@ -71,10 +71,10 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker {
if (LOG.isTraceEnabled()) {
LOG.trace("[#0] matches accepted pattern [#1]", value, acceptedPattern);
}
return IsAccepted.yes(acceptedPattern);
return IsAccepted.yes(acceptedPattern.toString());
}
}
return IsAccepted.no();
return IsAccepted.no(acceptedPatterns.toString());
}
public Set<Pattern> getAcceptedPatterns() {
@@ -83,7 +83,7 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker {
return IsExcluded.yes(excludedPattern);
}
}
return IsExcluded.no();
return IsExcluded.no(excludedPatterns);
}
public Set<Pattern> getExcludedPatterns() {
@@ -47,17 +47,17 @@ public interface ExcludedPatternsChecker {
public final static class IsExcluded {
private final boolean excluded;
private final Pattern excludedPattern;
private final String excludedPattern;
public static IsExcluded yes(Pattern excludedPattern) {
return new IsExcluded(true, excludedPattern);
return new IsExcluded(true, excludedPattern.pattern());
}
public static IsExcluded no() {
return new IsExcluded(false, null);
public static IsExcluded no(Set<Pattern> excludedPatterns) {
return new IsExcluded(false, excludedPatterns.toString());
}
private IsExcluded(boolean excluded, Pattern excludedPattern) {
private IsExcluded(boolean excluded, String excludedPattern) {
this.excluded = excluded;
this.excludedPattern = excludedPattern;
}
@@ -66,7 +66,7 @@ public interface ExcludedPatternsChecker {
return excluded;
}
public Pattern getExcludedPattern() {
public String getExcludedPattern() {
return excludedPattern;
}