Repository: james-project
Updated Branches:
  refs/heads/master 15ddf2d92 -> c89148658


JAMES-1968 Rework equals and hashcode in ScriptSummary


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

Branch: refs/heads/master
Commit: 027b0ca25b640c6f10224a4c0b4abaa1c9cd3e61
Parents: 15ddf2d
Author: benwa <btell...@linagora.com>
Authored: Fri Mar 17 11:31:58 2017 +0700
Committer: benwa <btell...@linagora.com>
Committed: Wed Mar 22 07:10:48 2017 +0700

----------------------------------------------------------------------
 server/data/data-api/pom.xml                    | 12 +++++++-
 .../sieverepository/api/ScriptSummary.java      | 25 ++++++++-------
 .../sieverepository/api/ScriptSummaryTest.java  | 32 ++++++++++++++++++++
 3 files changed, 55 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/027b0ca2/server/data/data-api/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-api/pom.xml b/server/data/data-api/pom.xml
index 484b3d6..f5f38a5 100644
--- a/server/data/data-api/pom.xml
+++ b/server/data/data-api/pom.xml
@@ -50,7 +50,17 @@
             <groupId>joda-time</groupId>
             <artifactId>joda-time</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>nl.jqno.equalsverifier</groupId>
+            <artifactId>equalsverifier</artifactId>
+            <version>1.7.6</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/james-project/blob/027b0ca2/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
 
b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
index b36b9df..5eeb08b 100644
--- 
a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
+++ 
b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/ScriptSummary.java
@@ -20,6 +20,8 @@
 
 package org.apache.james.sieverepository.api;
 
+import com.google.common.base.Objects;
+
 public class ScriptSummary {
 
     private final String name;
@@ -39,21 +41,18 @@ public class ScriptSummary {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof ScriptSummary)) return false;
-
-        ScriptSummary that = (ScriptSummary) o;
-
-        if (activeFile != that.activeFile) return false;
-        return !(name != null ? !name.equals(that.name) : that.name != null);
-
+    public final boolean equals(Object o) {
+        if (o instanceof ScriptSummary) {
+            ScriptSummary that = (ScriptSummary) o;
+
+            return Objects.equal(this.name, that.name)
+                && Objects.equal(this.activeFile, that.activeFile);
+        }
+        return false;
     }
 
     @Override
-    public int hashCode() {
-        int result = name != null ? name.hashCode() : 0;
-        result = 31 * result + (activeFile ? 1 : 0);
-        return result;
+    public final int hashCode() {
+        return Objects.hashCode(name, activeFile);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/027b0ca2/server/data/data-api/src/test/java/org/apache/james/sieverepository/api/ScriptSummaryTest.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-api/src/test/java/org/apache/james/sieverepository/api/ScriptSummaryTest.java
 
b/server/data/data-api/src/test/java/org/apache/james/sieverepository/api/ScriptSummaryTest.java
new file mode 100644
index 0000000..89d7e98
--- /dev/null
+++ 
b/server/data/data-api/src/test/java/org/apache/james/sieverepository/api/ScriptSummaryTest.java
@@ -0,0 +1,32 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.james.sieverepository.api;
+
+import org.junit.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class ScriptSummaryTest {
+    @Test
+    public void shouldRespectBeanContract() {
+        EqualsVerifier.forClass(ScriptSummary.class).verify();
+    }
+}


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

Reply via email to