james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [09/24] james-project git commit: JAMES-2366 Use OptionalUtils::or to better express logic in RRT processor
Date Tue, 03 Apr 2018 10:02:55 GMT
JAMES-2366 Use OptionalUtils::or to better express logic in RRT processor


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/fc278a8e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/fc278a8e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/fc278a8e

Branch: refs/heads/master
Commit: fc278a8e5fd0267f64e8fc901fc21900627194fb
Parents: 3e5c593
Author: benwa <btellier@linagora.com>
Authored: Wed Mar 28 13:23:51 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Apr 3 16:59:44 2018 +0700

----------------------------------------------------------------------
 .../transport/mailets/RecipientRewriteTableProcessor.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/fc278a8e/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
index 475b149..f48e132 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.transport.mailets;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
 import java.util.function.Function;
@@ -38,6 +39,7 @@ import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.Mapping;
 import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.util.OptionalUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
@@ -57,9 +59,11 @@ public class RecipientRewriteTableProcessor {
     private final MailetContext mailetContext;
 
     private static final Function<RrtExecutionResult, Stream<MailAddress>> mailAddressesFromMappingData
=
-        mappingData -> mappingData.getNewRecipients()
-            .orElse(mappingData.getRecipientWithError()
-                .orElse(ImmutableList.of())).stream();
+        mappingData ->
+                OptionalUtils.or(
+                    mappingData.getNewRecipients(),
+                    mappingData.getRecipientWithError())
+            .map(Collection::stream).orElse(Stream.of());
 
     private static final Function<Mapping, Optional<MailAddress>> mailAddressFromMapping
=
         addressMapping -> {


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message