added support for Integer > Float conversion.

Moved some tests from EvaluationTests into OperatorTests.
Fleshed out OperatorTests to verify type promotions for mixed type operands.
This commit is contained in:
Andy Clement
2008-08-18 17:54:01 +00:00
parent 776553cfbb
commit 48055c6e20
6 changed files with 72 additions and 45 deletions

View File

@@ -26,7 +26,6 @@ public class OperatorPlus extends Operator {
super(payload);
}
// TODO OperatorPlus is lacking a bit on implementation...
@Override
public Object getValue(ExpressionState state) throws EvaluationException {
SpelNode leftOp = getLeftOperand();

View File

@@ -220,11 +220,15 @@ public class StandardTypeConverter implements TypeConverter {
private static class ToFloatConverter implements StandardIndividualTypeConverter {
public Object convert(Object value) throws SpelException {
return ((Double) value).floatValue();
if (value instanceof Integer) {
return ((Integer)value).floatValue();
} else {
return ((Double) value).floatValue();
}
}
public Class<?>[] getFrom() {
return new Class<?>[] { Double.class };
return new Class<?>[] { Double.class, Integer.class };
}
public Class<?> getTo() {