MAILET-122 Improve GenericRecipientMatcher a bit
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/05d58609 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/05d58609 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/05d58609 Branch: refs/heads/master Commit: 05d586095e71167d44e4b2f01f08db2f055436a3 Parents: b936cf5 Author: Benoit Tellier <[email protected]> Authored: Wed Aug 31 14:16:02 2016 +0700 Committer: Benoit Tellier <[email protected]> Committed: Mon Oct 10 11:35:59 2016 +0200 ---------------------------------------------------------------------- .../apache/mailet/base/GenericRecipientMatcher.java | 16 +++++++++------- .../org/apache/james/transport/matchers/UserIs.java | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/05d58609/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java ---------------------------------------------------------------------- diff --git a/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java b/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java index ac204c0..c5b53d2 100644 --- a/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java +++ b/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java @@ -20,13 +20,15 @@ package org.apache.mailet.base; +import java.util.ArrayList; +import java.util.Collection; + import javax.mail.MessagingException; import org.apache.mailet.Mail; import org.apache.mailet.MailAddress; -import java.util.Collection; -import java.util.Vector; +import com.google.common.collect.ImmutableList; /** * GenericMatcher makes writing recipient based matchers easier. It provides @@ -47,13 +49,13 @@ public abstract class GenericRecipientMatcher extends GenericMatcher { * @return Collection the Collection of MailAddress objects that have been matched */ public final Collection<MailAddress> match(Mail mail) throws MessagingException { - Collection<MailAddress> matching = new Vector<MailAddress>(); - for (MailAddress rec : mail.getRecipients()) { - if (matchRecipient(rec)) { - matching.add(rec); + Collection<MailAddress> matching = new ArrayList<MailAddress>(); + for (MailAddress recipient : mail.getRecipients()) { + if (matchRecipient(recipient)) { + matching.add(recipient); } } - return matching; + return ImmutableList.copyOf(matching); } /** http://git-wip-us.apache.org/repos/asf/james-project/blob/05d58609/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java index 2dd81aa..b857c14 100644 --- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java +++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java @@ -45,7 +45,7 @@ public class UserIs extends GenericRecipientMatcher { throw new MessagingException("UserIs should have a condition composed of a list of local parts of mail addresses"); } users = ImmutableSet.copyOf(Splitter.on(", ").split(getCondition())); - if (users.size() < 1) { + if (users.isEmpty()) { throw new MessagingException("UserIs should have at least a user specified"); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
