コード例 #1
0
 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;
 }
コード例 #2
0
 @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;
     }
   }
 }