Lists { public static <X, Y> List<Y> map(List<X> inputs, Func<? super X, ? extends Y> mapper) { if (null == inputs) { return null; } else if (inputs.isEmpty()) { return Collections.emptyList(); } List<Y> out = new ArrayList<Y>(); for (X in : inputs) { out.add(mapper.eval(in)); } return out; } private  Lists(); static Y foldLeft(Y initial, List<X> inputList, Aggregator<? super X, Y> op); static Y foldRight(Y initial, List<X> inputList, Aggregator<? super X, Y> op); static List<Y> map(List<X> inputs, Func<? super X, ? extends Y> mapper); @SuppressWarnings("unchecked") static X[] toArray(List<X> inputs, Class<X> klazz); static List<X> distinct(List<X> inputs);  }
@Test public void testMap() { List<Integer> inputs = new ArrayList<Integer>(); inputs.add(Integer.valueOf(3)); inputs.add(Integer.valueOf(42)); List<Integer> expected = new ArrayList<Integer>(); expected.add(Integer.valueOf(6)); expected.add(Integer.valueOf(84)); List<Integer> actuals = Lists.map(inputs, new Lists.Func<Integer, Integer>() { @Override public Integer eval(Integer in) { return Integer.valueOf(2 * in.intValue()); } }); assertTrue(expected.equals(actuals)); }