You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/01/05 04:56:02 UTC

[james-project] 23/24: JAMES-3471 Computing uids and message ids from updated flags is easy

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit ebad11e25667ba12b1cf344417584ea66cc06e99
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Mon Jan 4 11:43:00 2021 +0700

    JAMES-3471 Computing uids and message ids from updated flags is easy
    
    Thus we don't need to add additional fields to manage them in FlagsUpdated.
---
 .../james/mailbox/events/MailboxListener.java      | 23 ++++++++--------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
index 3517801..11bb4e6 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
@@ -587,31 +587,26 @@ public interface MailboxListener {
      * A mailbox event related to updated flags
      */
     class FlagsUpdated extends MessageEvent {
-        private final List<MessageUid> uids;
-        private final List<MessageId> messageIds;
         private final List<UpdatedFlags> updatedFlags;
 
         public FlagsUpdated(MailboxSession.SessionId sessionId, Username username, MailboxPath path,
                             MailboxId mailboxId, List<UpdatedFlags> updatedFlags, EventId eventId) {
             super(sessionId, username, path, mailboxId, eventId);
             this.updatedFlags = ImmutableList.copyOf(updatedFlags);
-            this.uids = updatedFlags.stream()
-                .map(UpdatedFlags::getUid)
-                .collect(Guavate.toImmutableList());
-            this.messageIds = updatedFlags.stream()
-                .map(UpdatedFlags::getMessageId)
-                .filter(Optional::isPresent)
-                .map(Optional::get)
-                .collect(Guavate.toImmutableList());
         }
 
         @Override
         public Collection<MessageUid> getUids() {
-            return uids;
+            return updatedFlags.stream()
+                .map(UpdatedFlags::getUid)
+                .collect(Guavate.toImmutableList());
         }
 
         public Collection<MessageId> getMessageIds() {
-            return messageIds;
+            return updatedFlags.stream()
+                .map(UpdatedFlags::getMessageId)
+                .flatMap(Optional::stream)
+                .collect(Guavate.toImmutableList());
         }
 
         public List<UpdatedFlags> getUpdatedFlags() {
@@ -633,8 +628,6 @@ public interface MailboxListener {
                     && Objects.equals(this.username, that.username)
                     && Objects.equals(this.path, that.path)
                     && Objects.equals(this.mailboxId, that.mailboxId)
-                    && Objects.equals(this.uids, that.uids)
-                    && Objects.equals(this.messageIds, that.messageIds)
                     && Objects.equals(this.updatedFlags, that.updatedFlags);
             }
             return false;
@@ -642,7 +635,7 @@ public interface MailboxListener {
 
         @Override
         public final int hashCode() {
-            return Objects.hash(eventId, sessionId, username, path, mailboxId, uids, messageIds, updatedFlags);
+            return Objects.hash(eventId, sessionId, username, path, mailboxId, updatedFlags);
         }
     }
 


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