From 19ff7d84ab2763f86d5761af6238755e35532970 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 30 Oct 2019 14:31:46 +0100 Subject: [PATCH] Polishing --- .../context/annotation/DeferredImportSelector.java | 12 +++++++----- .../core/annotation/RepeatableContainers.java | 3 +-- ...SynthesizedMergedAnnotationInvocationHandler.java | 3 +-- .../java/org/springframework/util/unit/DataUnit.java | 4 +--- .../messaging/simp/user/MultiServerUserRegistry.java | 1 - .../java/org/springframework/http/MediaType.java | 8 ++++---- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java b/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java index 1dd9e5b511..6bca915678 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java @@ -16,8 +16,6 @@ package org.springframework.context.annotation; -import java.util.Objects; - import org.springframework.core.type.AnnotationMetadata; import org.springframework.lang.Nullable; @@ -108,13 +106,17 @@ public interface DeferredImportSelector extends ImportSelector { return false; } Entry entry = (Entry) other; - return (Objects.equals(this.metadata, entry.metadata) && - Objects.equals(this.importClassName, entry.importClassName)); + return (this.metadata.equals(entry.metadata) && this.importClassName.equals(entry.importClassName)); } @Override public int hashCode() { - return Objects.hash(this.metadata, this.importClassName); + return (this.metadata.hashCode() * 31 + this.importClassName.hashCode()); + } + + @Override + public String toString() { + return this.importClassName; } } } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/RepeatableContainers.java b/spring-core/src/main/java/org/springframework/core/annotation/RepeatableContainers.java index 01cb98c3fa..a235a581b0 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/RepeatableContainers.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/RepeatableContainers.java @@ -20,7 +20,6 @@ import java.lang.annotation.Annotation; import java.lang.annotation.Repeatable; import java.lang.reflect.Method; import java.util.Map; -import java.util.Objects; import org.springframework.lang.Nullable; import org.springframework.util.Assert; @@ -83,7 +82,7 @@ public abstract class RepeatableContainers { if (other == null || getClass() != other.getClass()) { return false; } - return Objects.equals(this.parent, ((RepeatableContainers) other).parent); + return ObjectUtils.nullSafeEquals(this.parent, ((RepeatableContainers) other).parent); } @Override diff --git a/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java b/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java index 89eab8386f..fe1131bf16 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java @@ -23,7 +23,6 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Arrays; import java.util.NoSuchElementException; -import java.util.Objects; import org.springframework.lang.Nullable; import org.springframework.util.Assert; @@ -90,7 +89,7 @@ final class SynthesizedMergedAnnotationInvocationHandler i } private boolean isAnnotationTypeMethod(Method method) { - return (Objects.equals(method.getName(), "annotationType") && method.getParameterCount() == 0); + return (method.getName().equals("annotationType") && method.getParameterCount() == 0); } /** diff --git a/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java b/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java index 3ade6a289b..8b5dc4354d 100644 --- a/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java +++ b/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java @@ -16,8 +16,6 @@ package org.springframework.util.unit; -import java.util.Objects; - /** * A standard set of {@link DataSize} units. * @@ -92,7 +90,7 @@ public enum DataUnit { */ public static DataUnit fromSuffix(String suffix) { for (DataUnit candidate : values()) { - if (Objects.equals(candidate.suffix, suffix)) { + if (candidate.suffix.equals(suffix)) { return candidate; } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java index 02c6249138..d33e8548b0 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java @@ -560,7 +560,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati } return map; } - } } diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index dbface9e54..f44b314822 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -109,7 +109,7 @@ public class MediaType extends MimeType implements Serializable { /** * Public constant media type for {@code application/json;charset=UTF-8}. - * @deprecated Deprecated as of Spring Framework 5.2 in favor of {@link #APPLICATION_JSON} + * @deprecated as of 5.2 in favor of {@link #APPLICATION_JSON} * since major browsers like Chrome * * now comply with the specification and interpret correctly UTF-8 special @@ -120,7 +120,7 @@ public class MediaType extends MimeType implements Serializable { /** * A String equivalent of {@link MediaType#APPLICATION_JSON_UTF8}. - * @deprecated Deprecated as of Spring Framework 5.2 in favor of {@link #APPLICATION_JSON_VALUE} + * @deprecated as of 5.2 in favor of {@link #APPLICATION_JSON_VALUE} * since major browsers like Chrome * * now comply with the specification and interpret correctly UTF-8 special @@ -170,7 +170,7 @@ public class MediaType extends MimeType implements Serializable { * @since 5.0 * @see * Problem Details for HTTP APIs, 6.1. application/problem+json - * @deprecated Deprecated as of Spring Framework 5.2 in favor of {@link #APPLICATION_PROBLEM_JSON} + * @deprecated as of 5.2 in favor of {@link #APPLICATION_PROBLEM_JSON} * since major browsers like Chrome * * now comply with the specification and interpret correctly UTF-8 special @@ -182,7 +182,7 @@ public class MediaType extends MimeType implements Serializable { /** * A String equivalent of {@link MediaType#APPLICATION_PROBLEM_JSON_UTF8}. * @since 5.0 - * @deprecated Deprecated as of Spring Framework 5.2 in favor of {@link #APPLICATION_PROBLEM_JSON_VALUE} + * @deprecated as of 5.2 in favor of {@link #APPLICATION_PROBLEM_JSON_VALUE} * since major browsers like Chrome * * now comply with the specification and interpret correctly UTF-8 special -- GitLab