SPR-6745: metadata (annotations) attached to property accessors allowing formatting of values during conversion

This commit is contained in:
Andy Clement
2010-02-12 01:50:52 +00:00
parent 0f65a0f239
commit 117b138233
15 changed files with 222 additions and 46 deletions

View File

@@ -108,6 +108,14 @@ public class ExpressionTestsUsingCoreConversionService extends ExpressionTestCas
public Object convertValue(Object value, TypeDescriptor typeDescriptor) throws EvaluationException {
return this.service.convert(value, TypeDescriptor.forObject(value), typeDescriptor);
}
public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
return this.service.canConvert(sourceType, targetType);
}
public Object convertValue(Object value, TypeDescriptor sourceType, TypeDescriptor targetType) throws EvaluationException {
return this.service.convert(value, sourceType, targetType);
}
}
}

View File

@@ -188,7 +188,7 @@ public class PropertyAccessTests extends ExpressionTestCase {
if (!name.equals("flibbles"))
throw new RuntimeException("Assertion Failed! name should be flibbles");
try {
flibbles = (Integer) context.getTypeConverter().convertValue(newValue, TypeDescriptor.valueOf(Integer.class));
flibbles = (Integer) context.getTypeConverter().convertValue(newValue, TypeDescriptor.forObject(newValue), TypeDescriptor.valueOf(Integer.class));
}catch (EvaluationException e) {
throw new AccessException("Cannot set flibbles to an object of type '" + newValue.getClass() + "'");
}

View File

@@ -72,7 +72,7 @@ public class StandardComponentsTests {
@Test
public void testStandardTypeConverter() throws EvaluationException {
TypeConverter tc = new StandardTypeConverter();
tc.convertValue(3, TypeDescriptor.valueOf(Double.class));
tc.convertValue(3, TypeDescriptor.forObject(3), TypeDescriptor.valueOf(Double.class));
}
}