JAMES-2122 Avoid confusing Optional boxing in JMAP mailboxFactory
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0624ab2e Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0624ab2e Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0624ab2e Branch: refs/heads/master Commit: 0624ab2e38c6d88432222c5efadbb4de0436bcbd Parents: 40c9816 Author: benwa <btell...@linagora.com> Authored: Thu Aug 17 10:39:04 2017 +0700 Committer: Matthieu Baechler <matth...@apache.org> Committed: Thu Aug 17 13:13:34 2017 +0200 ---------------------------------------------------------------------- .../apache/james/jmap/model/MailboxFactory.java | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/0624ab2e/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java index 119de23..23d327c 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MailboxFactory.java @@ -75,7 +75,7 @@ public class MailboxFactory { try { MessageManager mailbox = mailboxFactory.mailboxManager.getMailbox(id, session); - return mailboxFactory.fromMessageManager(mailbox, Optional.ofNullable(userMailboxesMetadata), session); + return Optional.of(mailboxFactory.fromMessageManager(mailbox, Optional.ofNullable(userMailboxesMetadata), session)); } catch (MailboxNotFoundException e) { return Optional.empty(); } catch (MailboxException e) { @@ -93,20 +93,20 @@ public class MailboxFactory { return new MailboxBuilder(this); } - private Optional<Mailbox> fromMessageManager(MessageManager messageManager, Optional<List<MailboxMetaData>> userMailboxesMetadata, + private Mailbox fromMessageManager(MessageManager messageManager, Optional<List<MailboxMetaData>> userMailboxesMetadata, MailboxSession mailboxSession) throws MailboxException { MailboxPath mailboxPath = messageManager.getMailboxPath(); Optional<Role> role = Role.from(mailboxPath.getName()); MailboxCounters mailboxCounters = messageManager.getMailboxCounters(mailboxSession); - return Optional.ofNullable(Mailbox.builder() - .id(messageManager.getId()) - .name(getName(mailboxPath, mailboxSession)) - .parentId(getParentIdFromMailboxPath(mailboxPath, userMailboxesMetadata, mailboxSession).orElse(null)) - .role(role) - .unreadMessages(mailboxCounters.getUnseen()) - .totalMessages(mailboxCounters.getCount()) - .sortOrder(SortOrder.getSortOrder(role)) - .build()); + return Mailbox.builder() + .id(messageManager.getId()) + .name(getName(mailboxPath, mailboxSession)) + .parentId(getParentIdFromMailboxPath(mailboxPath, userMailboxesMetadata, mailboxSession).orElse(null)) + .role(role) + .unreadMessages(mailboxCounters.getUnseen()) + .totalMessages(mailboxCounters.getCount()) + .sortOrder(SortOrder.getSortOrder(role)) + .build(); } @VisibleForTesting String getName(MailboxPath mailboxPath, MailboxSession mailboxSession) { --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org