james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [12/14] james-project git commit: JAMES-2525 uses single instanceof for all bean equality
Date Fri, 05 Oct 2018 11:12:55 GMT
JAMES-2525 uses single instanceof for all bean equality

This is as per project coding standard.


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

Branch: refs/heads/master
Commit: eec12864dee50085e886cabd21b38088e4727246
Parents: 6b9e2e9
Author: Jean Helou <jhe@codamens.fr>
Authored: Tue Oct 2 10:38:45 2018 +0200
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Oct 5 18:11:43 2018 +0700

----------------------------------------------------------------------
 .../blob/objectstorage/swift/Credentials.java   | 11 ++++------
 .../blob/objectstorage/swift/DomainId.java      | 11 ++++------
 .../blob/objectstorage/swift/DomainName.java    | 11 ++++------
 .../blob/objectstorage/swift/HeaderName.java    | 11 ++++------
 .../blob/objectstorage/swift/Identity.java      | 13 +++++-------
 .../blob/objectstorage/swift/IdentityV3.java    | 13 +++++-------
 .../james/blob/objectstorage/swift/Project.java | 17 +++++++---------
 .../blob/objectstorage/swift/ProjectName.java   | 11 ++++------
 .../james/blob/objectstorage/swift/Region.java  | 11 ++++------
 .../swift/SwiftKeystone2ObjectStorage.java      | 17 +++++++---------
 .../swift/SwiftKeystone3ObjectStorage.java      | 21 +++++++++-----------
 .../swift/SwiftTempAuthObjectStorage.java       | 21 +++++++++-----------
 .../blob/objectstorage/swift/TenantName.java    | 11 ++++------
 .../blob/objectstorage/swift/UserName.java      | 11 ++++------
 14 files changed, 74 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Credentials.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Credentials.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Credentials.java
index 46e4c84..2e4bde0 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Credentials.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Credentials.java
@@ -44,14 +44,11 @@ public final class Credentials {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof Credentials) {
+            Credentials that = (Credentials) o;
+            return Objects.equal(credentials, that.credentials);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        Credentials that = (Credentials) o;
-        return Objects.equal(credentials, that.credentials);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainId.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainId.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainId.java
index 8809dd0..1ec6d47 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainId.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainId.java
@@ -44,14 +44,11 @@ public final class DomainId {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof DomainId) {
+            DomainId that = (DomainId) o;
+            return Objects.equal(value, that.value);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        DomainId that = (DomainId) o;
-        return Objects.equal(value, that.value);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainName.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainName.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainName.java
index 89ae083..f08faea 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainName.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/DomainName.java
@@ -44,14 +44,11 @@ public final class DomainName {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof DomainName) {
+            DomainName that = (DomainName) o;
+            return Objects.equal(value, that.value);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        DomainName that = (DomainName) o;
-        return Objects.equal(value, that.value);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/HeaderName.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/HeaderName.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/HeaderName.java
index e62e317..03e0df1 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/HeaderName.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/HeaderName.java
@@ -40,14 +40,11 @@ public class HeaderName {
 
     @Override
     public final boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof HeaderName) {
+            HeaderName that = (HeaderName) o;
+            return Objects.equal(value, that.value);
         }
-        if (!(o instanceof HeaderName)) {
-            return false;
-        }
-        HeaderName that = (HeaderName) o;
-        return Objects.equal(value, that.value);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Identity.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Identity.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Identity.java
index 82d69b3..33e34bf 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Identity.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Identity.java
@@ -56,15 +56,12 @@ public final class Identity {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof Identity) {
+            Identity that = (Identity) o;
+            return Objects.equal(tenant, that.tenant) &&
+                Objects.equal(userName, that.userName);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        Identity identity = (Identity) o;
-        return Objects.equal(tenant, identity.tenant) &&
-            Objects.equal(userName, identity.userName);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/IdentityV3.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/IdentityV3.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/IdentityV3.java
index f636d7c..12d9f24 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/IdentityV3.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/IdentityV3.java
@@ -56,15 +56,12 @@ public final class IdentityV3 {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof IdentityV3) {
+            IdentityV3 that = (IdentityV3) o;
+            return Objects.equal(domainName, that.domainName) &&
+                Objects.equal(userName, that.userName);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        IdentityV3 identity = (IdentityV3) o;
-        return Objects.equal(domainName, identity.domainName) &&
-            Objects.equal(userName, identity.userName);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Project.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Project.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Project.java
index 394f763..435fced 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Project.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Project.java
@@ -45,7 +45,7 @@ public final class Project {
     private Project(ProjectName name, Optional<DomainName> domainName, Optional<DomainId>
domainId) {
         Preconditions.checkArgument(
             name != null,
-        this.getClass().getSimpleName() + "name cannot be null or empty");
+            this.getClass().getSimpleName() + "name cannot be null or empty");
         this.domainName = domainName;
         this.name = name;
         this.domainId = domainId;
@@ -65,16 +65,13 @@ public final class Project {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof Project) {
+            Project that = (Project) o;
+            return Objects.equal(name, that.name) &&
+                Objects.equal(domainName, that.domainName) &&
+                Objects.equal(domainId, that.domainId);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        Project project = (Project) o;
-        return Objects.equal(name, project.name) &&
-            Objects.equal(domainName, project.domainName) &&
-            Objects.equal(domainId, project.domainId);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/ProjectName.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/ProjectName.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/ProjectName.java
index e3eba57..2241cb2 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/ProjectName.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/ProjectName.java
@@ -48,14 +48,11 @@ public final class ProjectName {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof ProjectName) {
+            ProjectName that = (ProjectName) o;
+            return Objects.equal(value, that.value);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        ProjectName that = (ProjectName) o;
-        return Objects.equal(value, that.value);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Region.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Region.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Region.java
index a17b999..0f3f418 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Region.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/Region.java
@@ -44,14 +44,11 @@ public final class Region {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof Region) {
+            Region that = (Region) o;
+            return Objects.equal(region, that.region);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        Region region1 = (Region) o;
-        return Objects.equal(region, region1.region);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
index 1d26c9c..5ace285 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
@@ -168,17 +168,14 @@ public class SwiftKeystone2ObjectStorage {
 
         @Override
         public boolean equals(Object o) {
-            if (this == o) {
-                return true;
+            if (o instanceof Configuration) {
+                Configuration that = (Configuration) o;
+                return Objects.equal(endpoint, that.endpoint) &&
+                    Objects.equal(identity, that.identity) &&
+                    Objects.equal(region, that.region) &&
+                    Objects.equal(credentials, that.credentials);
             }
-            if (o == null || getClass() != o.getClass()) {
-                return false;
-            }
-            Configuration that = (Configuration) o;
-            return Objects.equal(endpoint, that.endpoint) &&
-                Objects.equal(identity, that.identity) &&
-                Objects.equal(region, that.region) &&
-                Objects.equal(credentials, that.credentials);
+            return false;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
index e544735..2e1986d 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
@@ -209,19 +209,16 @@ public class SwiftKeystone3ObjectStorage {
 
         @Override
         public boolean equals(Object o) {
-            if (this == o) {
-                return true;
+            if (o instanceof SwiftKeystone2ObjectStorage.Configuration) {
+                Configuration that = (Configuration) o;
+                return Objects.equal(endpoint, that.endpoint) &&
+                    Objects.equal(identity, that.identity) &&
+                    Objects.equal(region, that.region) &&
+                    Objects.equal(credentials, that.credentials) &&
+                    Objects.equal(project, that.project) &&
+                    Objects.equal(domainId, that.domainId);
             }
-            if (o == null || getClass() != o.getClass()) {
-                return false;
-            }
-            Configuration that = (Configuration) o;
-            return Objects.equal(endpoint, that.endpoint) &&
-                Objects.equal(identity, that.identity) &&
-                Objects.equal(region, that.region) &&
-                Objects.equal(credentials, that.credentials) &&
-                Objects.equal(project, that.project) &&
-                Objects.equal(domainId, that.domainId);
+            return false;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorage.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorage.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorage.java
index f65e558..48eeeb2 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorage.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorage.java
@@ -195,19 +195,16 @@ public class SwiftTempAuthObjectStorage {
 
         @Override
         public boolean equals(Object o) {
-            if (this == o) {
-                return true;
+            if (o instanceof SwiftKeystone2ObjectStorage.Configuration) {
+                Configuration that = (Configuration) o;
+                return Objects.equal(endpoint, that.endpoint) &&
+                    Objects.equal(identity, that.identity) &&
+                    Objects.equal(region, that.region) &&
+                    Objects.equal(credentials, that.credentials) &&
+                    Objects.equal(userHeaderName, that.userHeaderName) &&
+                    Objects.equal(passHeaderName, that.passHeaderName);
             }
-            if (o == null || getClass() != o.getClass()) {
-                return false;
-            }
-            Configuration that = (Configuration) o;
-            return Objects.equal(endpoint, that.endpoint) &&
-                Objects.equal(identity, that.identity) &&
-                Objects.equal(region, that.region) &&
-                Objects.equal(credentials, that.credentials) &&
-                Objects.equal(userHeaderName, that.userHeaderName) &&
-                Objects.equal(passHeaderName, that.passHeaderName);
+            return false;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/TenantName.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/TenantName.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/TenantName.java
index c59cf74..0ce4fc2 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/TenantName.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/TenantName.java
@@ -44,14 +44,11 @@ public final class TenantName {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof TenantName) {
+            TenantName that = (TenantName) o;
+            return Objects.equal(value, that.value);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        TenantName that = (TenantName) o;
-        return Objects.equal(value, that.value);
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/eec12864/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/UserName.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/UserName.java
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/UserName.java
index e4b310c..3cce24e 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/UserName.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/UserName.java
@@ -44,14 +44,11 @@ public final class UserName {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) {
-            return true;
+        if (o instanceof UserName) {
+            UserName that = (UserName) o;
+            return Objects.equal(value, that.value);
         }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        UserName that = (UserName) o;
-        return Objects.equal(value, that.value);
+        return false;
     }
 
     @Override


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


Mime
View raw message