naming improvements from mark fisher code review

This commit is contained in:
Keith Donald 2009-10-15 00:33:17 +00:00
parent 4563cb2804
commit 66d901b9fe
5 changed files with 20 additions and 20 deletions

View File

@ -24,7 +24,7 @@ import org.springframework.util.ClassUtils;
* @author Keith Donald * @author Keith Donald
* @see BeanUtils#instantiate(Class) * @see BeanUtils#instantiate(Class)
*/ */
final class DefaultMapperTargetFactory implements MapperTargetFactory { final class DefaultMappingTargetFactory implements MappingTargetFactory {
public boolean supports(TypeDescriptor targetType) { public boolean supports(TypeDescriptor targetType) {
return ClassUtils.hasConstructor(targetType.getType(), null); return ClassUtils.hasConstructor(targetType.getType(), null);

View File

@ -23,7 +23,7 @@ final class MappingConversionService extends DefaultConversionService {
@Override @Override
protected GenericConverter getDefaultConverter(TypeDescriptor sourceType, TypeDescriptor targetType) { protected GenericConverter getDefaultConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
return new MapperConverter(new SpelMapper()); return new MappingConverter(new SpelMapper());
} }
} }

View File

@ -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. * 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. * The default MapperTargetFactory instantiates a target by calling its default constructor.
* @author Keith Donald * @author Keith Donald
*/ */
public final class MapperConverter implements GenericConverter { public final class MappingConverter implements GenericConverter {
private Mapper mapper; private Mapper mapper;
private MapperTargetFactory mappingTargetFactory; private MappingTargetFactory mappingTargetFactory;
public MapperConverter(Mapper mapper) { public MappingConverter(Mapper mapper) {
this(mapper, new DefaultMapperTargetFactory()); this(mapper, new DefaultMappingTargetFactory());
} }
public MapperConverter(Mapper mapper, MapperTargetFactory mappingTargetFactory) { public MappingConverter(Mapper mapper, MappingTargetFactory mappingTargetFactory) {
this.mapper = mapper; this.mapper = mapper;
this.mappingTargetFactory = mappingTargetFactory; this.mappingTargetFactory = mappingTargetFactory;
} }

View File

@ -20,12 +20,12 @@ import org.springframework.mapping.Mapper;
/** /**
* A factory for customizing how the target of a map operation is constructed. * 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 * @author Keith Donald
* @see MapperConverter * @see MappingConverter
* @see Mapper#map(Object, Object) * @see Mapper#map(Object, Object)
*/ */
public interface MapperTargetFactory { public interface MappingTargetFactory {
/** /**
* Does this factory support creating mapping targets of the specified type * Does this factory support creating mapping targets of the specified type

View File

@ -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. * 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 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)}. * This method is a convenience method for {@link #addNestedMapper(Class, Class, Mapper)}.
* @param nestedMapper the nested 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. * 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 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}. * 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, MapperTargetFactory)}. * This method is a convenience method for {@link #addNestedMapper(Class, Class, Mapper, MappingTargetFactory)}.
* @param nestedMapper the nested mapper * @param nestedMapper the nested mapper
* @param targetFactory the nested mapper's target factory * @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); Class<?>[] typeInfo = getRequiredTypeInfo(nestedMapper);
addNestedMapper(typeInfo[0], typeInfo[1], nestedMapper, targetFactory); addNestedMapper(typeInfo[0], typeInfo[1], nestedMapper, targetFactory);
} }
/** /**
* Adds a Mapper that will map the fields of a nested sourceType/targetType pair. * 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 sourceType the source nested object property type
* @param targetType the target nested object property type * @param targetType the target nested object property type
* @param nestedMapper the nested mapper * @param nestedMapper the nested mapper
*/ */
public void addNestedMapper(Class<?> sourceType, Class<?> targetType, Mapper<?, ?> nestedMapper) { 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 * @param targetFactory the nested mapper's target factory
*/ */
public void addNestedMapper(Class<?> sourceType, Class<?> targetType, Mapper<?, ?> nestedMapper, public void addNestedMapper(Class<?> sourceType, Class<?> targetType, Mapper<?, ?> nestedMapper,
MapperTargetFactory targetFactory) { MappingTargetFactory targetFactory) {
this.conversionService.addGenericConverter(sourceType, targetType, new MapperConverter(nestedMapper)); 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. * 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. * To register the latter, consider using one of the {@link #addNestedMapper(Mapper) addNestedMapper} variants.
* @see Converter * @see Converter
* @see MapperConverter * @see MappingConverter
*/ */
public ConverterRegistry getConverterRegistry() { public ConverterRegistry getConverterRegistry() {
return conversionService; return conversionService;