generic converter updates
This commit is contained in:
parent
d3b43ebccb
commit
f1f4bd9fb4
|
|
@ -55,8 +55,8 @@ public class FormattingConversionServiceAdapter extends GenericConversionService
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GenericConverter getConverter(Class sourceType, TypeDescriptor targetType) {
|
protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
if (String.class.equals(sourceType)) {
|
if (String.class.equals(sourceType.getType())) {
|
||||||
Formatter formatter = this.formatterRegistry.getFormatter(targetType);
|
Formatter formatter = this.formatterRegistry.getFormatter(targetType);
|
||||||
if (formatter != null) {
|
if (formatter != null) {
|
||||||
return new FormattingConverter(formatter);
|
return new FormattingConverter(formatter);
|
||||||
|
|
@ -76,13 +76,18 @@ public class FormattingConversionServiceAdapter extends GenericConversionService
|
||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object convert(Object source, TypeDescriptor targetType) {
|
public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
|
throw new UnsupportedOperationException("Should not be called");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
try {
|
try {
|
||||||
return this.formatter.parse((String) source, LocaleContextHolder.getLocale());
|
return this.formatter.parse((String) source, LocaleContextHolder.getLocale());
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ex) {
|
||||||
throw new IllegalArgumentException("Could not convert formatted value '" + source + "'", ex);
|
throw new IllegalArgumentException("Could not convert formatted value '" + source + "'", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
package org.springframework.core.convert.support;
|
|
||||||
|
|
||||||
import org.springframework.core.convert.TypeDescriptor;
|
|
||||||
|
|
||||||
public interface MatchableGenericConverter extends GenericConverter {
|
|
||||||
|
|
||||||
boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType);
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue