You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/08/31 17:16:11 UTC

[tomcat] branch main updated: Add hashCode implementations that are aligned with existing equals()

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

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new cd094d8  Add hashCode implementations that are aligned with existing equals()
cd094d8 is described below

commit cd094d8bc7ed46c3410ea4555594738ac6cf5b1c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Aug 31 18:16:03 2021 +0100

    Add hashCode implementations that are aligned with existing equals()
---
 java/org/apache/catalina/users/GenericGroup.java | 8 ++++++++
 java/org/apache/catalina/users/GenericRole.java  | 8 ++++++++
 java/org/apache/catalina/users/GenericUser.java  | 8 ++++++++
 3 files changed, 24 insertions(+)

diff --git a/java/org/apache/catalina/users/GenericGroup.java b/java/org/apache/catalina/users/GenericGroup.java
index 2439788..153f5e5 100644
--- a/java/org/apache/catalina/users/GenericGroup.java
+++ b/java/org/apache/catalina/users/GenericGroup.java
@@ -179,4 +179,12 @@ public class GenericGroup<UD extends UserDatabase> extends AbstractGroup {
     }
 
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((database == null) ? 0 : database.hashCode());
+        result = prime * result + ((groupname == null) ? 0 : groupname.hashCode());
+        return result;
+    }
 }
diff --git a/java/org/apache/catalina/users/GenericRole.java b/java/org/apache/catalina/users/GenericRole.java
index 4da7c4d..2103714 100644
--- a/java/org/apache/catalina/users/GenericRole.java
+++ b/java/org/apache/catalina/users/GenericRole.java
@@ -98,4 +98,12 @@ public class GenericRole<UD extends UserDatabase> extends AbstractRole {
     }
 
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((database == null) ? 0 : database.hashCode());
+        result = prime * result + ((rolename == null) ? 0 : rolename.hashCode());
+        return result;
+    }
 }
diff --git a/java/org/apache/catalina/users/GenericUser.java b/java/org/apache/catalina/users/GenericUser.java
index 8788cbd..a020acd 100644
--- a/java/org/apache/catalina/users/GenericUser.java
+++ b/java/org/apache/catalina/users/GenericUser.java
@@ -254,4 +254,12 @@ public class GenericUser<UD extends UserDatabase> extends AbstractUser {
     }
 
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((database == null) ? 0 : database.hashCode());
+        result = prime * result + ((username == null) ? 0 : username.hashCode());
+        return result;
+    }
 }

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