Class identity comparisons wherever possible

Issue: SPR-12926
This commit is contained in:
Juergen Hoeller
2015-12-01 14:11:44 +01:00
parent b70af3bf57
commit 38c21ee6bf
2 changed files with 4 additions and 4 deletions

View File

@@ -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

View File

@@ -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?