NumberLibrary { public static double mean(Collection<? extends Number> values) { if (values.isEmpty()) { return 0.0; } return sum(values) / values.size(); }  static Function<String, Integer> methodParseInteger(); static int ifNegative(int number, int ifNegative); static int ifLessThan(int bound, int number, int ifLess); static int ifGreaterThan(int bound, int number, int ifGreater); static int bounded(int min, int max, int target); static int sumInts(Iterable<Integer> values); static long sumLongs(Iterable<Long> values); static double sum(Iterable<? extends Number> values); static double mean(Collection<? extends Number> values); static double median(Collection<? extends T> values);  }
@Test public void meanValueOfACollection() { Collection<Integer> empty = asList(); assertTrue(0.0 == mean(empty)); assertTrue(0.0 == mean(asList(-1, 0, 1))); assertTrue(0.0 == mean(asList(-2.2, 2.2))); }