MeanFunction extends UnaryFunction { public Double evaluate(Collection<?> values){ Mean statistic = new Mean(); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); statistic.increment(number.doubleValue()); } return statistic.getResult(); } MeanFunction();  MeanFunction(String name); Double evaluate(Collection<?> values); @Override FieldValue evaluate(FieldValue value);  }
@Test public void evaluate(){ List<Double> values = Arrays.asList(1d, 2d, 3d, 4d, 5d); assertEquals(3d, evaluate(values)); }