Replaced custom code by JRE standards
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/client/Entity.java b/jaxrs-api/src/main/java/jakarta/ws/rs/client/Entity.java
index df0d85f..4ec8984 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/client/Entity.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/client/Entity.java
@@ -19,6 +19,7 @@
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Locale;
+import java.util.Objects;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.MediaType;
@@ -260,13 +261,13 @@
Entity entity1 = (Entity) o;
- if (!Arrays.equals(annotations, entity1.annotations)) {
+ if (!Objects.equals(annotations, entity1.annotations)) {
return false;
}
- if (entity != null ? !entity.equals(entity1.entity) : entity1.entity != null) {
+ if (!Objects.equals(entity, entity1.entity)) {
return false;
}
- if (variant != null ? !variant.equals(entity1.variant) : entity1.variant != null) {
+ if (!Objects.equals(variant, entity1.variant)) {
return false;
}
@@ -275,10 +276,7 @@
@Override
public int hashCode() {
- int result = entity != null ? entity.hashCode() : 0;
- result = 31 * result + (variant != null ? variant.hashCode() : 0);
- result = 31 * result + Arrays.hashCode(annotations);
- return result;
+ return Objects.hash(annotations, entity, variant);
}
@Override
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/CacheControl.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/CacheControl.java
index 7175545..2760ea7 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/CacheControl.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/CacheControl.java
@@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import jakarta.ws.rs.ext.RuntimeDelegate;
import jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
@@ -339,15 +340,8 @@
*/
@Override
public int hashCode() {
- int hash = 7;
- hash = 41 * hash + (this.privateFlag ? 1 : 0);
- hash = 41 * hash + (this.noCache ? 1 : 0);
- hash = 41 * hash + (this.noStore ? 1 : 0);
- hash = 41 * hash + (this.noTransform ? 1 : 0);
- hash = 41 * hash + (this.mustRevalidate ? 1 : 0);
- hash = 41 * hash + (this.proxyRevalidate ? 1 : 0);
- hash = 41 * hash + this.maxAge;
- hash = 41 * hash + this.sMaxAge;
+ int hash = Objects.hash(this.privateFlag, this.noCache, this.noStore, this.noTransform, this.mustRevalidate,
+ this.proxyRevalidate, this.maxAge, this.sMaxAge);
hash = 41 * hash + hashCodeOf(this.privateFields);
hash = 41 * hash + hashCodeOf(this.noCacheFields);
hash = 41 * hash + hashCodeOf(this.cacheExtension);
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Cookie.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Cookie.java
index cc01fba..ba19e9b 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Cookie.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Cookie.java
@@ -16,6 +16,8 @@
package jakarta.ws.rs.core;
+import java.util.Objects;
+
import jakarta.ws.rs.ext.RuntimeDelegate;
import jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
@@ -197,13 +199,7 @@
*/
@Override
public int hashCode() {
- int hash = 7;
- hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
- hash = 97 * hash + (this.value != null ? this.value.hashCode() : 0);
- hash = 97 * hash + this.version;
- hash = 97 * hash + (this.path != null ? this.path.hashCode() : 0);
- hash = 97 * hash + (this.domain != null ? this.domain.hashCode() : 0);
- return hash;
+ return Objects.hash(this.name, this.value, this.version, this.path, this.domain);
}
/**
@@ -223,19 +219,19 @@
return false;
}
final Cookie other = (Cookie) obj;
- if (this.name != other.name && (this.name == null || !this.name.equals(other.name))) {
+ if (!Objects.equals(this.name, other.name)) {
return false;
}
- if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
+ if (!Objects.equals(this.value, other.value)) {
return false;
}
- if (this.version != other.version) {
+ if (!Objects.equals(this.version, other.version)) {
return false;
}
- if (this.path != other.path && (this.path == null || !this.path.equals(other.path))) {
+ if (!Objects.equals(this.path, other.path)) {
return false;
}
- if (this.domain != other.domain && (this.domain == null || !this.domain.equals(other.domain))) {
+ if (!Objects.equals(this.domain, other.domain)) {
return false;
}
return true;
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/GenericEntity.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/GenericEntity.java
index 6cf0913..3d904b3 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/GenericEntity.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/GenericEntity.java
@@ -23,6 +23,7 @@
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.util.Objects;
/**
* Represents a message entity of a generic type {@code T}.
@@ -179,7 +180,7 @@
@Override
public int hashCode() {
- return entity.hashCode() + type.hashCode() * 37 + 5;
+ return Objects.hash(entity, type);
}
@Override
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Link.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Link.java
index 6117f13..6f03b86 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Link.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Link.java
@@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Map.Entry;
import jakarta.ws.rs.ext.RuntimeDelegate;
@@ -518,9 +519,7 @@
@Override
public int hashCode() {
- int result = uri != null ? uri.hashCode() : 0;
- result = 31 * result + (params != null && !params.isEmpty() ? params.hashCode() : 0);
- return result;
+ return Objects.hash(uri, params);
}
}
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/NewCookie.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/NewCookie.java
index 13922a1..1b0a0d8 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/NewCookie.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/NewCookie.java
@@ -17,6 +17,7 @@
package jakarta.ws.rs.core;
import java.util.Date;
+import java.util.Objects;
import jakarta.ws.rs.ext.RuntimeDelegate;
import jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
@@ -423,14 +424,8 @@
*/
@Override
public int hashCode() {
- int hash = super.hashCode();
- hash = 59 * hash + (this.comment != null ? this.comment.hashCode() : 0);
- hash = 59 * hash + this.maxAge;
- hash = 59 + hash + (this.expiry != null ? this.expiry.hashCode() : 0);
- hash = 59 * hash + (this.secure ? 1 : 0);
- hash = 59 * hash + (this.httpOnly ? 1 : 0);
- hash = 59 * hash + (this.sameSite != null ? this.sameSite.ordinal() : 0);
- return hash;
+ return Objects.hash(this.getName(), this.getValue(), this.getVersion(), this.getPath(), this.getDomain(),
+ this.comment, this.maxAge, this.expiry, this.secure, this.httpOnly, this.sameSite);
}
/**
@@ -450,29 +445,29 @@
return false;
}
final NewCookie other = (NewCookie) obj;
- if (this.getName() != other.getName() && (this.getName() == null || !this.getName().equals(other.getName()))) {
+ if (!Objects.equals(this.getName(), other.getName())) {
return false;
}
- if (this.getValue() != other.getValue() && (this.getValue() == null || !this.getValue().equals(other.getValue()))) {
+ if (!Objects.equals(this.getValue(), other.getValue())) {
return false;
}
if (this.getVersion() != other.getVersion()) {
return false;
}
- if (this.getPath() != other.getPath() && (this.getPath() == null || !this.getPath().equals(other.getPath()))) {
+ if (!Objects.equals(this.getPath(), other.getPath())) {
return false;
}
- if (this.getDomain() != other.getDomain() && (this.getDomain() == null || !this.getDomain().equals(other.getDomain()))) {
+ if (!Objects.equals(this.getDomain(), other.getDomain())) {
return false;
}
- if (this.comment != other.comment && (this.comment == null || !this.comment.equals(other.comment))) {
+ if (!Objects.equals(this.comment, other.comment)) {
return false;
}
if (this.maxAge != other.maxAge) {
return false;
}
- if (this.expiry != other.expiry && (this.expiry == null || !this.expiry.equals(other.expiry))) {
+ if (!Objects.equals(this.expiry, other.expiry)) {
return false;
}
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
index d7b98c3..b48bc6b 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
@@ -19,6 +19,7 @@
import java.io.StringWriter;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import jakarta.ws.rs.ext.RuntimeDelegate;
@@ -198,11 +199,7 @@
*/
@Override
public int hashCode() {
- int hash = 7;
- hash = 29 * hash + (this.language != null ? this.language.hashCode() : 0);
- hash = 29 * hash + (this.mediaType != null ? this.mediaType.hashCode() : 0);
- hash = 29 * hash + (this.encoding != null ? this.encoding.hashCode() : 0);
- return hash;
+ return Objects.hash(this.language, this.mediaType, this.encoding);
}
/**
@@ -220,14 +217,13 @@
return false;
}
final Variant other = (Variant) obj;
- if (this.language != other.language && (this.language == null || !this.language.equals(other.language))) {
+ if (!Objects.equals(this.language, other.language)) {
return false;
}
- if (this.mediaType != other.mediaType && (this.mediaType == null || !this.mediaType.equals(other.mediaType))) {
+ if (!Objects.equals(this.mediaType, other.mediaType)) {
return false;
}
- // noinspection StringEquality
- return this.encoding == other.encoding || (this.encoding != null && this.encoding.equals(other.encoding));
+ return Objects.equals(this.encoding, other.encoding);
}
@Override