NhincCollections { public static <T> List<T> fillAbsents(List<Optional<T>> list, final T fillValue) { Function<Optional<T>, T> helper = new Function<Optional<T>, T>() { @Override public T apply(Optional<T> t) { if (t != null) { return t.or(fillValue); } else { return null; } } }; return Lists.transform(list, helper); } private  NhincCollections(); static List<T> fillAbsents(List<Optional<T>> list, final T fillValue); static List<T> combine(List<T> listA, final List<T> listB); static List<T> addAll(List<T> addTo, final List<T> addWith); static List<T> addAllWith(List<T> addTo, final List<T> addWith, final boolean allowDuplicate); static boolean equalsIgnoreCaseAny(List<String> listA, List<String> listB); final static boolean ALLOW_DUPLICATE; final static boolean NO_DUPLICATE; }
@Test public void fillAbsents() { List<Optional<String>> input = new ArrayList<>(); input.add(Optional.<String> absent()); input.add(Optional.of("test")); List<String> output = NhincCollections.fillAbsents(input, "testFillValue"); assertEquals("testFillValue", output.get(0)); assertEquals("test", output.get(1)); }