james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [13/15] james-project git commit: PROTOCOLS-117 Bonus: Functional style in MailboxPath constructor
Date Fri, 03 Nov 2017 12:27:36 GMT
PROTOCOLS-117 Bonus: Functional style in MailboxPath constructor


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

Branch: refs/heads/master
Commit: 28b75a051290aa9d2fd80d1fe8f1efd3b2c3bdbb
Parents: deefc33
Author: benwa <btellier@linagora.com>
Authored: Wed Nov 1 09:37:56 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Nov 3 15:48:40 2017 +0700

----------------------------------------------------------------------
 .../java/org/apache/james/mailbox/model/MailboxPath.java    | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/28b75a05/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
index 1da70bc..1ba8d67 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.model;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 import org.apache.james.mailbox.MailboxSession;
 
@@ -77,11 +78,9 @@ public class MailboxPath {
     private String name;
     
     public MailboxPath(String namespace, String user, String name) {
-        if (namespace == null || namespace.equals("")) {
-            this.namespace = MailboxConstants.USER_NAMESPACE;
-        } else {
-            this.namespace = namespace;
-        }
+        this.namespace = Optional.ofNullable(namespace)
+            .filter(s -> !s.isEmpty())
+            .orElse(MailboxConstants.USER_NAMESPACE);
         this.user = user;
         this.name = name;
     }


---------------------------------------------------------------------
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