From 38c21ee6bfd1b71b3ae1c451106880f6b7cbb630 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 1 Dec 2015 14:11:44 +0100 Subject: [PATCH] Class identity comparisons wherever possible Issue: SPR-12926 --- .../core/convert/converter/GenericConverter.java | 4 ++-- .../core/convert/support/GenericConversionService.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/convert/converter/GenericConverter.java b/spring-core/src/main/java/org/springframework/core/convert/converter/GenericConverter.java index 11bc2945a7..09d3b10837 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/converter/GenericConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/converter/GenericConverter.java @@ -67,7 +67,7 @@ public interface GenericConverter { /** * Holder for a source-to-target class pair. */ - public static final class ConvertiblePair { + final class ConvertiblePair { private final Class sourceType; @@ -102,7 +102,7 @@ public interface GenericConverter { return false; } ConvertiblePair otherPair = (ConvertiblePair) other; - return (this.sourceType.equals(otherPair.sourceType) && this.targetType.equals(otherPair.targetType)); + return (this.sourceType == otherPair.sourceType && this.targetType == otherPair.targetType); } @Override diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java index 6ec4b309ab..52df6a7766 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java @@ -231,7 +231,7 @@ public class GenericConversionService implements ConfigurableConversionService { * @return the converted null object */ protected Object convertNullSource(TypeDescriptor sourceType, TypeDescriptor targetType) { - if (javaUtilOptionalEmpty != null && targetType.getObjectType().equals(javaUtilOptionalEmpty.getClass())) { + if (javaUtilOptionalEmpty != null && targetType.getObjectType() == javaUtilOptionalEmpty.getClass()) { return javaUtilOptionalEmpty; } return null; @@ -354,7 +354,7 @@ public class GenericConversionService implements ConfigurableConversionService { @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { // Check raw type first... - if (!this.typeInfo.getTargetType().equals(targetType.getObjectType())) { + if (this.typeInfo.getTargetType() != targetType.getObjectType()) { return false; } // Full check for complex generic type match required?