Object leftValue = expression.getLeft().execute(configuration, processingContext, expContext);
Object rightValue = expression.getRight().execute(configuration, processingContext, expContext);
if (leftValue == null || rightValue == null) {
throw new TemplateProcessingException(
"Cannot execute LESS OR EQUAL TO comparison: operands are \"" + LiteralValue.unwrap(leftValue) + "\" and \"" + LiteralValue.unwrap(rightValue) + "\"");
}
leftValue = LiteralValue.unwrap(leftValue);
rightValue = LiteralValue.unwrap(rightValue);
Boolean result = null;
final BigDecimal leftNumberValue = EvaluationUtil.evaluateAsNumber(leftValue);
final BigDecimal rightNumberValue = EvaluationUtil.evaluateAsNumber(rightValue);
if (leftNumberValue != null && rightNumberValue != null) {
result = Boolean.valueOf(leftNumberValue.compareTo(rightNumberValue) != 1);
} else {
if (leftValue != null && rightValue != null &&
leftValue.getClass().equals(rightValue.getClass()) &&
Comparable.class.isAssignableFrom(leftValue.getClass())) {
result = Boolean.valueOf(((Comparable<Object>)leftValue).compareTo(rightValue) <= 0);
} else {
throw new TemplateProcessingException(
"Cannot execute LESS OR EQUAL TO from Expression \"" +
expression.getStringRepresentation() + "\". Left is \"" +
leftValue + "\", right is \"" + rightValue + "\"");
}
}