@Test public void testMap() { assertEquals("map for an empty list", IList.of(), el.map(x -> x * 2)); assertEquals("map for a non-empty list", IList.of(-1, -2, -3, -4), nel.map(i -> -i)); }
public abstract <U> IList<U> map(F<? super T, ? extends U> f);
IList implements Iterable<T> { public abstract <U> IList<U> map(F<? super T, ? extends U> f); }
IList implements Iterable<T> { public abstract <U> IList<U> map(F<? super T, ? extends U> f);  }
IList implements Iterable<T> { public abstract <U> IList<U> map(F<? super T, ? extends U> f);  @SuppressWarnings("unchecked") static IList<T> empty(); static IList<T> of(); static NonEmpty<T> of(T elem); @SafeVarargs static NonEmpty<T> of(T elem, T... elems); static IList<T> ofIterable(Iterable<T> elems); static IList<T> ofArray(T[] elems); static IList<T> concat(IList<? extends T> l1, IList<? extends T>  l2); static String listToString(IList<Character> l); static IList<Character> stringToList(String s); NonEmpty<T> add(T head); IList<T> addAll(IList<S> l); abstract boolean isEmpty(); abstract Optional<NonEmpty<T>> nonEmptyOpt(); abstract T head(); abstract IList<T> tail(); abstract T get(int index); abstract StringBuilder append(StringBuilder sb); @Override @SuppressWarnings("unchecked") boolean equals(Object rhs); @Override int hashCode(); abstract boolean equals(IList<T> rhs); abstract S match(F<NonEmpty<T>, S> nonEmptyF, F<Empty<T>, S> emptyF); abstract IList<T> appendAll(IList<? extends T> l); abstract int size(); abstract IList<T> reverse(); abstract IList<U> map(F<? super T, ? extends U> f); abstract IList<U> flatMap(F<? super T, IList<? extends U>> f); abstract U foldRight(F2<T, U, U> f, U z); abstract U foldLeft(F2<U, T, U> f, U z); @Override abstract Spliterator<T> spliterator(); Stream<T> stream(); Stream<T> parallelStream(); @Override abstract Iterator<T> iterator(); abstract List<T> toList(); }
IList implements Iterable<T> { public abstract <U> IList<U> map(F<? super T, ? extends U> f);  @SuppressWarnings("unchecked") static IList<T> empty(); static IList<T> of(); static NonEmpty<T> of(T elem); @SafeVarargs static NonEmpty<T> of(T elem, T... elems); static IList<T> ofIterable(Iterable<T> elems); static IList<T> ofArray(T[] elems); static IList<T> concat(IList<? extends T> l1, IList<? extends T>  l2); static String listToString(IList<Character> l); static IList<Character> stringToList(String s); NonEmpty<T> add(T head); IList<T> addAll(IList<S> l); abstract boolean isEmpty(); abstract Optional<NonEmpty<T>> nonEmptyOpt(); abstract T head(); abstract IList<T> tail(); abstract T get(int index); abstract StringBuilder append(StringBuilder sb); @Override @SuppressWarnings("unchecked") boolean equals(Object rhs); @Override int hashCode(); abstract boolean equals(IList<T> rhs); abstract S match(F<NonEmpty<T>, S> nonEmptyF, F<Empty<T>, S> emptyF); abstract IList<T> appendAll(IList<? extends T> l); abstract int size(); abstract IList<T> reverse(); abstract IList<U> map(F<? super T, ? extends U> f); abstract IList<U> flatMap(F<? super T, IList<? extends U>> f); abstract U foldRight(F2<T, U, U> f, U z); abstract U foldLeft(F2<U, T, U> f, U z); @Override abstract Spliterator<T> spliterator(); Stream<T> stream(); Stream<T> parallelStream(); @Override abstract Iterator<T> iterator(); abstract List<T> toList();  }