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:
@@ -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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user