### Question:
DoubleMeanValueAggregatorFunction implements Function<List<Double>, Double> { public Double evaluate(List<Double> data) { if (data == null || data.size() == 0) { return null; } double mean = 0.0; int n = data.size(); for (Double d : data) { mean += d.doubleValue(); } mean /= n; return mean; }  Double evaluate(List<Double> data); @Override String toString();  }### Answer:
@Test public void testEmptyList() throws Exception { DoubleMeanValueAggregatorFunction fct = (DoubleMeanValueAggregatorFunction)makeFunctor(); List<Double> lst = null; Double res = fct.evaluate(lst); assertNull( res ); lst = new ArrayList<Double>(); res = fct.evaluate(lst); assertNull( res ); }
@Test public void testMean() throws Exception { DoubleMeanValueAggregatorFunction fct = (DoubleMeanValueAggregatorFunction)makeFunctor(); List<Double> lst = new ArrayList<Double>(); lst.add( 0.0 ); double res = fct.evaluate(lst); assertEquals(res, 0.0, 0.01); lst.add( 1.0 ); res = fct.evaluate( lst ); assertEquals( res, 0.5, 0.01 ); lst.add( 2.0 ); res = fct.evaluate( lst ); assertEquals( res, 1.0, 0.01 ); int calls = 31; double total; for( int i = 2; i <= calls; i++ ) { lst.clear(); total = 0.0; for( int j = 1; j <= i; j++ ) { lst.add( (double)j ); total += j; } total /= i; res = fct.evaluate( lst ); assertEquals( res, total, 0.01 ); } }