You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2016/09/15 10:08:55 UTC
[14/17] james-project git commit: MAILET-124 And should use recursion
MAILET-124 And should use recursion
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d1b0b8d8
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d1b0b8d8
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d1b0b8d8
Branch: refs/heads/master
Commit: d1b0b8d84cca847da7046291d522b9cb06a7a0f3
Parents: c8648a1
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Sep 8 14:58:46 2016 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Thu Sep 15 12:06:37 2016 +0200
----------------------------------------------------------------------
.../apache/james/mailetcontainer/impl/matchers/And.java | 12 ++++--------
.../james/mailetcontainer/impl/matchers/AndTest.java | 6 +++---
2 files changed, 7 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/d1b0b8d8/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java
index 9738495..f556a73 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java
@@ -50,19 +50,15 @@ public class And extends GenericCompositeMatcher {
return computeIntersection(individualMatchedResults);
}
- private Collection<MailAddress> computeIntersection(List<Set<MailAddress>> individualMatchedResults) {
+ private Set<MailAddress> computeIntersection(List<Set<MailAddress>> individualMatchedResults) {
if (individualMatchedResults.size() == 0) {
- return null;
+ return ImmutableSet.of();
}
if (individualMatchedResults.size() == 1) {
return individualMatchedResults.get(0);
}
- Set<MailAddress> temporaryResult = ImmutableSet.copyOf(individualMatchedResults.get(0));
- List<Set<MailAddress>> followingResults = individualMatchedResults.subList(1, individualMatchedResults.size());
- for(Set<MailAddress> matchedAddresses: followingResults) {
- temporaryResult = Sets.intersection(temporaryResult, matchedAddresses);
- }
- return temporaryResult;
+ return Sets.intersection(individualMatchedResults.get(0),
+ computeIntersection(individualMatchedResults.subList(1, individualMatchedResults.size())));
}
private List<Set<MailAddress>> performMatchOnMatchers(Mail mail) throws MessagingException {
http://git-wip-us.apache.org/repos/asf/james-project/blob/d1b0b8d8/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
index 1ec5d76..490b248 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
@@ -53,7 +53,7 @@ public class AndTest {
@Test
public void shouldNotMatchWhenNoChild() throws Exception {
- assertThat(testee.match(mail)).isNull();
+ assertThat(testee.match(mail)).isEmpty();
}
@Test
@@ -84,7 +84,7 @@ public class AndTest {
testee.add(matcher1);
testee.add(matcher2);
- assertThat(testee.match(mail)).isNull();
+ assertThat(testee.match(mail)).isEmpty();
}
@Test
@@ -95,6 +95,6 @@ public class AndTest {
testee.add(matcher1);
testee.add(matcher2);
- assertThat(testee.match(mail)).isNull();
+ assertThat(testee.match(mail)).isEmpty();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org