SEC-2825: Polish

This commit is contained in:
Rob Winch 2015-02-24 18:11:47 -06:00
parent ef3b9de766
commit f198804504
3 changed files with 18 additions and 21 deletions

View File

@ -28,8 +28,8 @@ import org.apache.commons.logging.Log;
* *
* @since 4.0 * @since 4.0
*/ */
public abstract class AbstractMessageMatcherComposite<T> implements MessageMatcher<T> { abstract class AbstractMessageMatcherComposite<T> implements MessageMatcher<T> {
private final Log logger = getLog(getClass()); protected final Log LOGGER = getLog(getClass());
private final List<MessageMatcher<T>> messageMatchers; private final List<MessageMatcher<T>> messageMatchers;
@ -53,17 +53,14 @@ public abstract class AbstractMessageMatcherComposite<T> implements MessageMatch
* @param messageMatchers the {@link MessageMatcher} instances to try * @param messageMatchers the {@link MessageMatcher} instances to try
*/ */
@SafeVarargs @SafeVarargs
public AbstractMessageMatcherComposite(MessageMatcher<T>... messagetMatchers) { public AbstractMessageMatcherComposite(MessageMatcher<T>... messageMatchers) {
this(asList(messagetMatchers)); this(asList(messageMatchers));
} }
public List<MessageMatcher<T>> getMessageMatchers() { public List<MessageMatcher<T>> getMessageMatchers() {
return messageMatchers; return messageMatchers;
} }
public Log getLogger() {
return logger;
}
@Override @Override
public String toString() { public String toString() {
return getClass().getSimpleName()+ "[messageMatchers=" + messageMatchers + "]"; return getClass().getSimpleName()+ "[messageMatchers=" + messageMatchers + "]";

View File

@ -24,7 +24,7 @@ import org.springframework.messaging.Message;
* *
* @since 4.0 * @since 4.0
*/ */
public class AndMessageMatcher<T> extends AbstractMessageMatcherComposite<T> { public final class AndMessageMatcher<T> extends AbstractMessageMatcherComposite<T> {
/** /**
* Creates a new instance * Creates a new instance
* *
@ -40,23 +40,23 @@ public class AndMessageMatcher<T> extends AbstractMessageMatcherComposite<T> {
* @param messageMatchers the {@link MessageMatcher} instances to try * @param messageMatchers the {@link MessageMatcher} instances to try
*/ */
@SafeVarargs @SafeVarargs
public AndMessageMatcher(MessageMatcher<T>... messagetMatchers) { public AndMessageMatcher(MessageMatcher<T>... messageMatchers) {
super(messagetMatchers); super(messageMatchers);
} }
@Override @Override
public boolean matches(Message<? extends T> message) { public boolean matches(Message<? extends T> message) {
for (MessageMatcher<T> matcher : getMessageMatchers()) { for (MessageMatcher<T> matcher : getMessageMatchers()) {
if (getLogger().isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
getLogger().debug("Trying to match using " + matcher); LOGGER.debug("Trying to match using " + matcher);
} }
if (!matcher.matches(message)) { if (!matcher.matches(message)) {
getLogger().debug("Did not match"); LOGGER.debug("Did not match");
return false; return false;
} }
} }
getLogger().debug("All messagetMatchers returned true"); LOGGER.debug("All messageMatchers returned true");
return true; return true;
} }
} }

View File

@ -24,7 +24,7 @@ import org.springframework.messaging.Message;
* *
* @since 4.0 * @since 4.0
*/ */
public class OrMessageMatcher<T> extends AbstractMessageMatcherComposite<T> { public final class OrMessageMatcher<T> extends AbstractMessageMatcherComposite<T> {
/** /**
* Creates a new instance * Creates a new instance
* *
@ -40,23 +40,23 @@ public class OrMessageMatcher<T> extends AbstractMessageMatcherComposite<T> {
* @param messageMatchers the {@link MessageMatcher} instances to try * @param messageMatchers the {@link MessageMatcher} instances to try
*/ */
@SafeVarargs @SafeVarargs
public OrMessageMatcher(MessageMatcher<T>... messagetMatchers) { public OrMessageMatcher(MessageMatcher<T>... messageMatchers) {
super(messagetMatchers); super(messageMatchers);
} }
@Override @Override
public boolean matches(Message<? extends T> message) { public boolean matches(Message<? extends T> message) {
for (MessageMatcher<T> matcher : getMessageMatchers()) { for (MessageMatcher<T> matcher : getMessageMatchers()) {
if (getLogger().isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
getLogger().debug("Trying to match using " + matcher); LOGGER.debug("Trying to match using " + matcher);
} }
if (matcher.matches(message)) { if (matcher.matches(message)) {
getLogger().debug("matched"); LOGGER.debug("matched");
return true; return true;
} }
} }
getLogger().debug("No matches found"); LOGGER.debug("No matches found");
return false; return false;
} }
} }