DATACMNS-683 - Tweaked the matching algorithm for DomainClassConverter.

DomainClassConverter as well as its internal ToEntity- and ToIdConverter implementations now actively refrain from matching if the source type is assignable to the target one to prevent unnecessary conversion attempts if the source value already actually is assignable to the target type.

Related ticket: DATACMNS-583.
This commit is contained in:
Oliver Gierke
2015-04-13 17:40:40 +02:00
parent d48fddf9e6
commit 9977c61667
2 changed files with 42 additions and 10 deletions

View File

@@ -166,12 +166,12 @@ public class DomainClassConverter<T extends ConversionService & ConverterRegistr
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
if (!repositories.hasRepositoryFor(targetType.getType())) {
if (sourceType.isAssignableTo(targetType)) {
return false;
}
if (sourceType.equals(targetType)) {
return true;
if (!repositories.hasRepositoryFor(targetType.getType())) {
return false;
}
Class<?> rawIdType = repositories.getRepositoryInformationFor(targetType.getType()).getIdType();
@@ -192,7 +192,7 @@ public class DomainClassConverter<T extends ConversionService & ConverterRegistr
* @author Oliver Gierke
* @since 1.10
*/
private class ToIdConverter implements ConditionalGenericConverter {
class ToIdConverter implements ConditionalGenericConverter {
/*
* (non-Javadoc)
@@ -232,12 +232,12 @@ public class DomainClassConverter<T extends ConversionService & ConverterRegistr
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
if (!repositories.hasRepositoryFor(sourceType.getType())) {
if (sourceType.isAssignableTo(targetType)) {
return false;
}
if (sourceType.equals(targetType)) {
return true;
if (!repositories.hasRepositoryFor(sourceType.getType())) {
return false;
}
Class<?> rawIdType = repositories.getRepositoryInformationFor(sourceType.getType()).getIdType();