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 ma...@apache.org on 2017/09/29 07:21:53 UTC

[15/31] james-project git commit: MAILBOX-307 Removing Unnecessary 'convertRightsToList'

MAILBOX-307 Removing Unnecessary 'convertRightsToList'


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

Branch: refs/heads/master
Commit: 06b06b667a7bfc36a724618b160aafd8cc84d091
Parents: 54f5d8d
Author: benwa <bt...@linagora.com>
Authored: Wed Sep 27 16:34:24 2017 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Fri Sep 29 09:20:40 2017 +0200

----------------------------------------------------------------------
 .../org/apache/james/mailbox/model/MailboxACL.java     | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/06b06b66/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java
index de7c8f2..f93a5ef 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java
@@ -241,7 +241,8 @@ public class MailboxACL {
          */
         public Rfc4314Rights except(Rfc4314Rights toRemove) throws UnsupportedRightException {
             EnumSet<Right> copy = copyOf(value);
-            copy.removeAll(convertRightsToList(toRemove));
+            Optional.ofNullable(toRemove)
+                .ifPresent(rights -> copy.removeAll(rights.value));
             return new Rfc4314Rights(copy);
         }
 
@@ -313,18 +314,10 @@ public class MailboxACL {
             Preconditions.checkNotNull(toAdd);
             EnumSet<Right> rightUnion = EnumSet.noneOf(Right.class);
             rightUnion.addAll(value);
-            rightUnion.addAll(convertRightsToList(toAdd));
+            rightUnion.addAll(toAdd.value);
             return new Rfc4314Rights(rightUnion);
         }
 
-        private List<Right> convertRightsToList(Rfc4314Rights toAdd) {
-            return Optional.ofNullable(toAdd).orElse(Rfc4314Rights.empty())
-                .list()
-                .stream()
-                .map(Throwing.function(right -> Right.forChar(right.asCharacter())))
-                .collect(Guavate.toImmutableList());
-        }
-
         private static Rfc4314Rights empty() {
             return new Rfc4314Rights();
         }


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