polishing
This commit is contained in:
parent
f751acea12
commit
18c63f70c4
|
|
@ -73,8 +73,8 @@ public class FormattingConversionService extends GenericConversionService
|
||||||
public Class<?>[][] getConvertibleTypes() {
|
public Class<?>[][] getConvertibleTypes() {
|
||||||
return new Class<?>[][] {{fieldType, String.class}};
|
return new Class<?>[][] {{fieldType, String.class}};
|
||||||
}
|
}
|
||||||
public boolean matches(TypeDescriptor sourceFieldType, TypeDescriptor targetFieldType) {
|
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
return (sourceFieldType.getAnnotation(annotationType) != null);
|
return (sourceType.getAnnotation(annotationType) != null);
|
||||||
}
|
}
|
||||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
Printer<?> printer = annotationFormatterFactory.getPrinter(sourceType.getAnnotation(annotationType), sourceType.getType());
|
Printer<?> printer = annotationFormatterFactory.getPrinter(sourceType.getAnnotation(annotationType), sourceType.getType());
|
||||||
|
|
@ -89,8 +89,8 @@ public class FormattingConversionService extends GenericConversionService
|
||||||
public Class<?>[][] getConvertibleTypes() {
|
public Class<?>[][] getConvertibleTypes() {
|
||||||
return new Class<?>[][] {{String.class, fieldType}};
|
return new Class<?>[][] {{String.class, fieldType}};
|
||||||
}
|
}
|
||||||
public boolean matches(TypeDescriptor sourceFieldType, TypeDescriptor targetFieldType) {
|
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
return (targetFieldType.getAnnotation(annotationType) != null);
|
return (targetType.getAnnotation(annotationType) != null);
|
||||||
}
|
}
|
||||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
Parser<?> parser = annotationFormatterFactory.getParser(targetType.getAnnotation(annotationType), targetType.getType());
|
Parser<?> parser = annotationFormatterFactory.getParser(targetType.getAnnotation(annotationType), targetType.getType());
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.core.convert.support;
|
package org.springframework.core.convert.support;
|
||||||
|
|
||||||
import org.springframework.core.convert.ConversionService;
|
|
||||||
import org.springframework.core.convert.converter.ConverterRegistry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory for creating common ConversionService configurations.
|
* A factory for common ConversionService configurations.
|
||||||
*
|
*
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
|
@ -31,7 +29,7 @@ public abstract class ConversionServiceFactory {
|
||||||
/**
|
/**
|
||||||
* Create a new default ConversionService instance that can be safely modified.
|
* Create a new default ConversionService instance that can be safely modified.
|
||||||
*/
|
*/
|
||||||
public static ConversionService createDefaultConversionService() {
|
public static GenericConversionService createDefaultConversionService() {
|
||||||
GenericConversionService conversionService = new GenericConversionService();
|
GenericConversionService conversionService = new GenericConversionService();
|
||||||
addDefaultConverters(conversionService);
|
addDefaultConverters(conversionService);
|
||||||
return conversionService;
|
return conversionService;
|
||||||
|
|
@ -39,7 +37,6 @@ public abstract class ConversionServiceFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the given ConversionService instance with all applicable default converters.
|
* Populate the given ConversionService instance with all applicable default converters.
|
||||||
* Callers may cast the returned ConversionService to a {@link ConverterRegistry} to supplement or override the default converters.
|
|
||||||
*/
|
*/
|
||||||
public static void addDefaultConverters(GenericConversionService conversionService) {
|
public static void addDefaultConverters(GenericConversionService conversionService) {
|
||||||
conversionService.addGenericConverter(new ArrayToArrayConverter(conversionService));
|
conversionService.addGenericConverter(new ArrayToArrayConverter(conversionService));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue