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 ro...@apache.org on 2020/06/08 13:15:56 UTC

[james-project] 02/30: JAMES-3179 Define MailboxACL.hashCode

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

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

commit 5f10d7039a23f16e7daf435a3d1b3ceaa1b5042c
Author: Gautier DI FOLCO <gd...@linagora.com>
AuthorDate: Tue May 12 14:06:31 2020 +0200

    JAMES-3179 Define MailboxACL.hashCode
---
 .../java/org/apache/james/mailbox/model/MailboxACL.java    | 14 ++++++++++----
 .../org/apache/james/mailbox/model/MailboxACLTest.java     | 11 +++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

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 8a7d692..e0d58ae 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,10 +241,16 @@ public class MailboxACL {
             return value.containsAll(Arrays.asList(rights));
         }
 
-        public boolean equals(Object o) {
+        @Override
+        public final int hashCode() {
+            return Objects.hash(value);
+        }
+
+        @Override
+        public final boolean equals(Object o) {
             if (o instanceof Rfc4314Rights) {
                 Rfc4314Rights that = (Rfc4314Rights) o;
-                return this.value.equals(that.value);
+                return Objects.equals(this.value, that.value);
             }
             return false;
         }
@@ -717,7 +723,7 @@ public class MailboxACL {
         this(toMap(props));
     }
 
-    public boolean equals(Object o) {
+    public final boolean equals(Object o) {
         if (o instanceof MailboxACL) {
             MailboxACL acl = (MailboxACL) o;
             return Objects.equals(this.getEntries(), acl.getEntries());
@@ -725,7 +731,7 @@ public class MailboxACL {
         return false;
     }
 
-    public int hashCode() {
+    public final int hashCode() {
         return Objects.hash(entries);
     }
 
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java
index f299efa..f53fad2 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java
@@ -37,6 +37,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableMap;
+import nl.jqno.equalsverifier.EqualsVerifier;
 
 class MailboxACLTest {
 
@@ -71,6 +72,16 @@ class MailboxACLTest {
     }
 
     @Test
+    void shouldRespectBeanContract() {
+        EqualsVerifier.forClass(MailboxACL.class).verify();
+    }
+
+    @Test
+    void rfc4314RightsShouldRespectBeanContract() {
+        EqualsVerifier.forClass(MailboxACL.Rfc4314Rights.class).verify();
+    }
+
+    @Test
     void testUnionACLNew() throws UnsupportedRightException {
 
         Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries());


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