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/10/07 09:25:14 UTC
[tomcat] 03/03: Add Eclipse IDE generated equals and hashCode
implementations.
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
commit 0b3c99c4e9c4cdce91a969430b01750291c86c1f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 7 10:23:37 2021 +0100
Add Eclipse IDE generated equals and hashCode implementations.
Aligns with Jakarta Servlet API
---
java/jakarta/servlet/http/Cookie.java | 52 +++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/java/jakarta/servlet/http/Cookie.java b/java/jakarta/servlet/http/Cookie.java
index 85d67b7..de184f2 100644
--- a/java/jakarta/servlet/http/Cookie.java
+++ b/java/jakarta/servlet/http/Cookie.java
@@ -544,6 +544,58 @@ public class Cookie implements Cloneable, Serializable {
return Collections.unmodifiableMap(attributes);
}
}
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((attributes == null) ? 0 : attributes.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ result = prime * result + version;
+ return result;
+ }
+
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Cookie other = (Cookie) obj;
+ if (attributes == null) {
+ if (other.attributes != null) {
+ return false;
+ }
+ } else if (!attributes.equals(other.attributes)) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (value == null) {
+ if (other.value != null) {
+ return false;
+ }
+ } else if (!value.equals(other.value)) {
+ return false;
+ }
+ if (version != other.version) {
+ return false;
+ }
+ return true;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org