SPR-8718 Minor polish
This commit is contained in:
parent
369f6f032b
commit
4199d772cc
|
|
@ -57,7 +57,7 @@ final class CollectionToCollectionConverter implements ConditionalGenericConvert
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
boolean isCopyRequired = !targetType.getType().isInstance(source);
|
boolean copyRequired = !targetType.getType().isInstance(source);
|
||||||
Collection<?> sourceCollection = (Collection<?>) source;
|
Collection<?> sourceCollection = (Collection<?>) source;
|
||||||
Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), sourceCollection.size());
|
Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), sourceCollection.size());
|
||||||
if (targetType.getElementTypeDescriptor() == null) {
|
if (targetType.getElementTypeDescriptor() == null) {
|
||||||
|
|
@ -70,11 +70,11 @@ final class CollectionToCollectionConverter implements ConditionalGenericConvert
|
||||||
Object targetElement = this.conversionService.convert(sourceElement, sourceType.elementTypeDescriptor(sourceElement), targetType.getElementTypeDescriptor());
|
Object targetElement = this.conversionService.convert(sourceElement, sourceType.elementTypeDescriptor(sourceElement), targetType.getElementTypeDescriptor());
|
||||||
target.add(targetElement);
|
target.add(targetElement);
|
||||||
if (sourceElement != targetElement) {
|
if (sourceElement != targetElement) {
|
||||||
isCopyRequired = true;
|
copyRequired = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isCopyRequired ? target : source;
|
return copyRequired ? target : source;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ final class MapToMapConverter implements ConditionalGenericConverter {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
boolean isCopyRequired = !targetType.getType().isInstance(source);
|
boolean copyRequired = !targetType.getType().isInstance(source);
|
||||||
Map<Object, Object> sourceMap = (Map<Object, Object>) source;
|
Map<Object, Object> sourceMap = (Map<Object, Object>) source;
|
||||||
Map<Object, Object> targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size());
|
Map<Object, Object> targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size());
|
||||||
for (Map.Entry<Object, Object> entry : sourceMap.entrySet()) {
|
for (Map.Entry<Object, Object> entry : sourceMap.entrySet()) {
|
||||||
|
|
@ -67,10 +67,10 @@ final class MapToMapConverter implements ConditionalGenericConverter {
|
||||||
Object targetValue = convertValue(sourceValue, sourceType, targetType.getMapValueTypeDescriptor());
|
Object targetValue = convertValue(sourceValue, sourceType, targetType.getMapValueTypeDescriptor());
|
||||||
targetMap.put(targetKey, targetValue);
|
targetMap.put(targetKey, targetValue);
|
||||||
if (sourceKey != targetKey || sourceValue != targetValue) {
|
if (sourceKey != targetKey || sourceValue != targetValue) {
|
||||||
isCopyRequired = true;
|
copyRequired = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isCopyRequired ? targetMap : sourceMap;
|
return copyRequired ? targetMap : sourceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal helpers
|
// internal helpers
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue