public ExpressionMeasurable(final String expression, final Unit<Q> unit) { try { this.expression = JexlUtil.newExpression(expression); } catch (final Exception e) { throw new IllegalArgumentException("Expression " + expression + " is not valid", e); } this.unit = unit; }
@Override public Double getValue() { if (this.expression == null) { return Double.NaN; } else { try { return Double.valueOf( JexlUtil.evaluateExpression(this.context, this.expression).toString()); } catch (final NullPointerException e) { return 0.0; } } }