refined generic converter concept

This commit is contained in:
Keith Donald
2009-09-18 19:57:59 +00:00
parent 6420fd303b
commit d3b43ebccb
14 changed files with 290 additions and 173 deletions

View File

@@ -101,21 +101,11 @@ public class ExpressionTestsUsingCoreConversionService extends ExpressionTestCas
private final DefaultConversionService service = new DefaultConversionService();
public boolean canConvert(Class<?> sourceType, Class<?> targetType) {
return this.service.canConvert(sourceType, TypeDescriptor.valueOf(targetType));
return this.service.canConvert(sourceType, targetType);
}
public boolean canConvert(Class<?> sourceType, TypeDescriptor typeDescriptor) {
return this.service.canConvert(sourceType, typeDescriptor);
}
@SuppressWarnings("cast")
public <T> T convertValue(Object value, Class<T> targetType) throws EvaluationException {
return (T) this.service.convert(value,TypeDescriptor.valueOf(targetType));
}
@SuppressWarnings("unchecked")
public Object convertValue(Object value, TypeDescriptor typeDescriptor) throws EvaluationException {
return this.service.convert(value, typeDescriptor);
return this.service.convert(value, TypeDescriptor.forObject(value), typeDescriptor);
}
}