naming improvements from mark fisher code review
This commit is contained in:
parent
4563cb2804
commit
66d901b9fe
|
|
@ -24,7 +24,7 @@ import org.springframework.util.ClassUtils;
|
|||
* @author Keith Donald
|
||||
* @see BeanUtils#instantiate(Class)
|
||||
*/
|
||||
final class DefaultMapperTargetFactory implements MapperTargetFactory {
|
||||
final class DefaultMappingTargetFactory implements MappingTargetFactory {
|
||||
|
||||
public boolean supports(TypeDescriptor targetType) {
|
||||
return ClassUtils.hasConstructor(targetType.getType(), null);
|
||||
|
|
@ -23,7 +23,7 @@ final class MappingConversionService extends DefaultConversionService {
|
|||
|
||||
@Override
|
||||
protected GenericConverter getDefaultConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
return new MapperConverter(new SpelMapper());
|
||||
return new MappingConverter(new SpelMapper());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,21 +23,21 @@ import org.springframework.mapping.Mapper;
|
|||
|
||||
/**
|
||||
* Adapts a Mapper to a Converter, allowing the conversion between two object types to be completed by a Mapper.
|
||||
* Delegates to a {@link MapperTargetFactory} to construct the conversion target object that will be mapped.
|
||||
* Delegates to a {@link MappingTargetFactory} to construct the conversion target object that will be mapped.
|
||||
* The default MapperTargetFactory instantiates a target by calling its default constructor.
|
||||
* @author Keith Donald
|
||||
*/
|
||||
public final class MapperConverter implements GenericConverter {
|
||||
public final class MappingConverter implements GenericConverter {
|
||||
|
||||
private Mapper mapper;
|
||||
|
||||
private MapperTargetFactory mappingTargetFactory;
|
||||
private MappingTargetFactory mappingTargetFactory;
|
||||
|
||||
public MapperConverter(Mapper mapper) {
|
||||
this(mapper, new DefaultMapperTargetFactory());
|
||||
public MappingConverter(Mapper mapper) {
|
||||
this(mapper, new DefaultMappingTargetFactory());
|
||||
}
|
||||
|
||||
public MapperConverter(Mapper mapper, MapperTargetFactory mappingTargetFactory) {
|
||||
public MappingConverter(Mapper mapper, MappingTargetFactory mappingTargetFactory) {
|
||||
this.mapper = mapper;
|
||||
this.mappingTargetFactory = mappingTargetFactory;
|
||||
}
|
||||
|
|
@ -20,12 +20,12 @@ import org.springframework.mapping.Mapper;
|
|||
|
||||
/**
|
||||
* A factory for customizing how the target of a map operation is constructed.
|
||||
* Used by a {@link MapperConverter} when executing a type conversion.
|
||||
* Used by a {@link MappingConverter} when executing a type conversion.
|
||||
* @author Keith Donald
|
||||
* @see MapperConverter
|
||||
* @see MappingConverter
|
||||
* @see Mapper#map(Object, Object)
|
||||
*/
|
||||
public interface MapperTargetFactory {
|
||||
public interface MappingTargetFactory {
|
||||
|
||||
/**
|
||||
* Does this factory support creating mapping targets of the specified type
|
||||
|
|
@ -126,7 +126,7 @@ public class SpelMapper implements Mapper<Object, Object> {
|
|||
/**
|
||||
* Adds a Mapper that will map the fields of a nested sourceType/targetType pair.
|
||||
* The source and target field types are determined by introspecting the parameterized types on the implementation's Mapper generic interface.
|
||||
* The target instance that is mapped is constructed by a {@link DefaultMapperTargetFactory}.
|
||||
* The target instance that is mapped is constructed by a {@link DefaultMappingTargetFactory}.
|
||||
* This method is a convenience method for {@link #addNestedMapper(Class, Class, Mapper)}.
|
||||
* @param nestedMapper the nested mapper
|
||||
*/
|
||||
|
|
@ -138,25 +138,25 @@ public class SpelMapper implements Mapper<Object, Object> {
|
|||
/**
|
||||
* Adds a Mapper that will map the fields of a nested sourceType/targetType pair.
|
||||
* The source and target field types are determined by introspecting the parameterized types on the implementation's Mapper generic interface.
|
||||
* The target instance that is mapped is constructed by the provided {@link MapperTargetFactory}.
|
||||
* This method is a convenience method for {@link #addNestedMapper(Class, Class, Mapper, MapperTargetFactory)}.
|
||||
* The target instance that is mapped is constructed by the provided {@link MappingTargetFactory}.
|
||||
* This method is a convenience method for {@link #addNestedMapper(Class, Class, Mapper, MappingTargetFactory)}.
|
||||
* @param nestedMapper the nested mapper
|
||||
* @param targetFactory the nested mapper's target factory
|
||||
*/
|
||||
public void addNestedMapper(Mapper<?, ?> nestedMapper, MapperTargetFactory targetFactory) {
|
||||
public void addNestedMapper(Mapper<?, ?> nestedMapper, MappingTargetFactory targetFactory) {
|
||||
Class<?>[] typeInfo = getRequiredTypeInfo(nestedMapper);
|
||||
addNestedMapper(typeInfo[0], typeInfo[1], nestedMapper, targetFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Mapper that will map the fields of a nested sourceType/targetType pair.
|
||||
* The target instance that is mapped is constructed by a {@link DefaultMapperTargetFactory}.
|
||||
* The target instance that is mapped is constructed by a {@link DefaultMappingTargetFactory}.
|
||||
* @param sourceType the source nested object property type
|
||||
* @param targetType the target nested object property type
|
||||
* @param nestedMapper the nested mapper
|
||||
*/
|
||||
public void addNestedMapper(Class<?> sourceType, Class<?> targetType, Mapper<?, ?> nestedMapper) {
|
||||
this.conversionService.addGenericConverter(sourceType, targetType, new MapperConverter(nestedMapper));
|
||||
this.conversionService.addGenericConverter(sourceType, targetType, new MappingConverter(nestedMapper));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -167,8 +167,8 @@ public class SpelMapper implements Mapper<Object, Object> {
|
|||
* @param targetFactory the nested mapper's target factory
|
||||
*/
|
||||
public void addNestedMapper(Class<?> sourceType, Class<?> targetType, Mapper<?, ?> nestedMapper,
|
||||
MapperTargetFactory targetFactory) {
|
||||
this.conversionService.addGenericConverter(sourceType, targetType, new MapperConverter(nestedMapper));
|
||||
MappingTargetFactory targetFactory) {
|
||||
this.conversionService.addGenericConverter(sourceType, targetType, new MappingConverter(nestedMapper));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -176,7 +176,7 @@ public class SpelMapper implements Mapper<Object, Object> {
|
|||
* Allows for registration of simple type Converters in addition to MapperConverters that map entire nested object structures using a Mapper.
|
||||
* To register the latter, consider using one of the {@link #addNestedMapper(Mapper) addNestedMapper} variants.
|
||||
* @see Converter
|
||||
* @see MapperConverter
|
||||
* @see MappingConverter
|
||||
*/
|
||||
public ConverterRegistry getConverterRegistry() {
|
||||
return conversionService;
|
||||
|
|
|
|||
Loading…
Reference in New Issue