@Test public void wrap(){ Chain<Integer> three = Chain.wrap(LazySeq.of(10,20,30)); assertThat(three,equalTo(Seq.of(10,20,30))); assertThat(three.size(),equalTo(3)); assertThat(three.isEmpty(),equalTo(false)); assertThat(three.toString(),equalTo("[10, 20, 30]")); }
public static <T> Chain<T> wrap(Iterable<T> it){ Iterator<T> i = it.iterator(); return i.hasNext() ? new Wrap(it) : empty(); }
Chain implements ImmutableList<T> { public static <T> Chain<T> wrap(Iterable<T> it){ Iterator<T> i = it.iterator(); return i.hasNext() ? new Wrap(it) : empty(); } }
Chain implements ImmutableList<T> { public static <T> Chain<T> wrap(Iterable<T> it){ Iterator<T> i = it.iterator(); return i.hasNext() ? new Wrap(it) : empty(); }  }
Chain implements ImmutableList<T> { public static <T> Chain<T> wrap(Iterable<T> it){ Iterator<T> i = it.iterator(); return i.hasNext() ? new Wrap(it) : empty(); }  static Chain<T> narrow(Chain<? extends T> broad); static EmptyChain<T> empty(); static NonEmptyChain<T> of(T... values); static NonEmptyChain<T> singleton(T value); static NonEmptyChain<T> append(NonEmptyChain<? extends T> left, NonEmptyChain<? extends T> right); static NonEmptyChain<T> append(Chain<? extends T> left, NonEmptyChain<? extends T> right); static NonEmptyChain<T> append(NonEmptyChain<? extends T> left, Chain<? extends T> right); static Chain<T> wrap(Iterable<T> it); abstract Chain<T> concat(Chain<T> b); @Override Chain<R> unitStream(Stream<R> stream); abstract boolean isEmpty(); abstract Iterator<T> iterator(); @Override Chain<R> zipWithStream(Stream<? extends U> other, BiFunction<? super T, ? super U, ? extends R> zipper); @Override Chain<Tuple2<T, U>> zipWithStream(Stream<? extends U> other); @Override Chain<T> insertStreamAt(int pos, Stream<T> stream); @Override Chain<T> prependStream(Stream<? extends T> stream); @Override Chain<T> removeStream(Stream<? extends T> stream); @Override Chain<T> retainStream(Stream<? extends T> stream); @Override Chain<R> unitIterable(Iterable<R> it); @Override EmptyChain<T> emptyUnit(); @Override Chain<T> drop(long num); @Override Chain<T> take(long num); @Override NonEmptyChain<T> prepend(T value); abstract Chain<T> prependAll(Iterable< ? extends T> value); @Override NonEmptyChain<T> append(T value); @Override abstract Chain<T> appendAll(Iterable<? extends T> value); @Override Chain<T> reverse(); @Override abstract Option<T> get(int pos); @Override abstract T getOrElse(int pos, T alt); @Override abstract T getOrElseGet(int pos, Supplier<? extends T> alt); @Override abstract int size(); @Override ReactiveSeq<T> stream(); @Override Chain<T> filter(Predicate<? super T> fn); @Override abstract Chain<R> map(Function<? super T, ? extends R> fn); @Override Chain<R> flatMap(Function<? super T, ? extends ImmutableList<? extends R>> fn); @Override abstract R fold(Function<? super Some<T>, ? extends R> fn1, Function<? super None<T>, ? extends R> fn2); @Override abstract NonEmptyChain<T> onEmpty(T value); @Override abstract NonEmptyChain<T> onEmptyGet(Supplier<? extends T> supplier); @Override Chain<T> onEmptySwitch(Supplier<? extends ImmutableList<T>> supplier); @Override Chain<R> concatMap(Function<? super T, ? extends Iterable<? extends R>> mapper); @Override Chain<R> mergeMap(Function<? super T, ? extends Publisher<? extends R>> fn); @Override Chain<R> mergeMap(int maxConcurecy, Function<? super T, ? extends Publisher<? extends R>> fn); @Override Chain<T> replaceFirst(T currentElement, T newElement); @Override Chain<T> removeFirst(Predicate<? super T> pred); @Override Chain<T> subList(int start, int end); @Override Chain<U> ofType(Class<? extends U> type); @Override Chain<T> filterNot(Predicate<? super T> predicate); @Override Chain<T> notNull(); @Override Chain<T> peek(Consumer<? super T> c); @Override Chain<T> tailOrElse(ImmutableList<T> tail); @Override Chain<R> forEach4(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends Iterable<R2>> iterable2, Function3<? super T, ? super R1, ? super R2, ? extends Iterable<R3>> iterable3, Function4<? super T, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction); @Override Chain<R> forEach4(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends Iterable<R2>> iterable2, Function3<? super T, ? super R1, ? super R2, ? extends Iterable<R3>> iterable3, Function4<? super T, ? super R1, ? super R2, ? super R3, Boolean> filterFunction, Function4<? super T, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction); @Override Chain<R> forEach3(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends Iterable<R2>> iterable2, Function3<? super T, ? super R1, ? super R2, ? extends R> yieldingFunction); @Override Chain<R> forEach3(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends Iterable<R2>> iterable2, Function3<? super T, ? super R1, ? super R2, Boolean> filterFunction, Function3<? super T, ? super R1, ? super R2, ? extends R> yieldingFunction); @Override Chain<R> forEach2(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction); @Override Chain<R> forEach2(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, Boolean> filterFunction, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction); @Override Chain<T> removeAt(long pos); @Override Chain<T> removeAll(T... values); @Override Chain<T> retainAll(Iterable<? extends T> it); @Override Chain<T> retainAll(T... values); @Override Chain<ReactiveSeq<T>> permutations(); @Override Chain<ReactiveSeq<T>> combinations(int size); @Override Chain<ReactiveSeq<T>> combinations(); @Override Chain<R> zip(BiFunction<? super T, ? super T2, ? extends R> fn, Publisher<? extends T2> publisher); @Override Chain<Tuple2<T, U>> zipWithPublisher(Publisher<? extends U> other); @Override Chain<Tuple2<T, U>> zip(Iterable<? extends U> other); @Override Chain<R> zip3(Iterable<? extends S> second, Iterable<? extends U> third, Function3<? super T, ? super S, ? super U, ? extends R> fn3); @Override Chain<R> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth, Function4<? super T, ? super T2, ? super T3, ? super T4, ? extends R> fn); @Override Chain<T> combine(BiPredicate<? super T, ? super T> predicate, BinaryOperator<T> op); @Override Chain<T> combine(Monoid<T> op, BiPredicate<? super T, ? super T> predicate); @Override Chain<T> cycle(long times); @Override Chain<T> cycle(Monoid<T> m, long times); @Override Chain<T> cycleWhile(Predicate<? super T> predicate); @Override Chain<T> cycleUntil(Predicate<? super T> predicate); @Override Chain<R> zip(Iterable<? extends U> other, BiFunction<? super T, ? super U, ? extends R> zipper); @Override Chain<Tuple3<T, S, U>> zip3(Iterable<? extends S> second, Iterable<? extends U> third); @Override Chain<Tuple4<T, T2, T3, T4>> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth); @Override Chain<Tuple2<T, Long>> zipWithIndex(); @Override Chain<Seq<T>> sliding(int windowSize); @Override Chain<Seq<T>> sliding(int windowSize, int increment); @Override Chain<C> grouped(int size, Supplier<C> supplier); @Override Chain<Vector<T>> groupedUntil(Predicate<? super T> predicate); @Override Chain<Vector<T>> groupedUntil(BiPredicate<Vector<? super T>, ? super T> predicate); @Override Chain<Vector<T>> groupedWhile(Predicate<? super T> predicate); @Override Chain<C> groupedWhile(Predicate<? super T> predicate, Supplier<C> factory); @Override Chain<C> groupedUntil(Predicate<? super T> predicate, Supplier<C> factory); @Override Chain<Vector<T>> grouped(int groupSize); @Override Chain<T> distinct(); @Override Chain<T> scanLeft(Monoid<T> monoid); @Override Chain<U> scanLeft(U seed, BiFunction<? super U, ? super T, ? extends U> function); @Override Chain<T> scanRight(Monoid<T> monoid); @Override Chain<U> scanRight(U identity, BiFunction<? super T, ? super U, ? extends U> combiner); @Override Chain<T> sorted(); @Override Chain<T> sorted(Comparator<? super T> c); @Override Chain<T> takeWhile(Predicate<? super T> p); @Override Chain<T> dropWhile(Predicate<? super T> p); @Override Chain<T> takeUntil(Predicate<? super T> p); @Override Chain<T> dropUntil(Predicate<? super T> p); @Override Chain<T> dropRight(int num); @Override Chain<T> takeRight(int num); @Override Chain<T> intersperse(T value); @Override Chain<T> shuffle(); @Override Chain<T> shuffle(Random random); @Override Chain<T> slice(long from, long to); @Override Chain<T> sorted(Function<? super T, ? extends U> function); @Override NonEmptyChain<T> appendAll(T... values); @Override NonEmptyChain<T> prependAll(T... values); @Override Chain<T> insertAt(int pos, T... values); @Override Chain<T> deleteBetween(int start, int end); @Override Chain<T> plusAll(Iterable<? extends T> list); @Override NonEmptyChain<T> plus(T value); @Override Chain<T> removeValue(T value); @Override Chain<T> removeAll(Iterable<? extends T> value); @Override Chain<T> updateAt(int pos, T value); @Override Chain<T> insertAt(int pos, Iterable<? extends T> values); @Override Chain<T> insertAt(int i, T value); abstract Iterator<T> reverseIterator(); }
Chain implements ImmutableList<T> { public static <T> Chain<T> wrap(Iterable<T> it){ Iterator<T> i = it.iterator(); return i.hasNext() ? new Wrap(it) : empty(); }  static Chain<T> narrow(Chain<? extends T> broad); static EmptyChain<T> empty(); static NonEmptyChain<T> of(T... values); static NonEmptyChain<T> singleton(T value); static NonEmptyChain<T> append(NonEmptyChain<? extends T> left, NonEmptyChain<? extends T> right); static NonEmptyChain<T> append(Chain<? extends T> left, NonEmptyChain<? extends T> right); static NonEmptyChain<T> append(NonEmptyChain<? extends T> left, Chain<? extends T> right); static Chain<T> wrap(Iterable<T> it); abstract Chain<T> concat(Chain<T> b); @Override Chain<R> unitStream(Stream<R> stream); abstract boolean isEmpty(); abstract Iterator<T> iterator(); @Override Chain<R> zipWithStream(Stream<? extends U> other, BiFunction<? super T, ? super U, ? extends R> zipper); @Override Chain<Tuple2<T, U>> zipWithStream(Stream<? extends U> other); @Override Chain<T> insertStreamAt(int pos, Stream<T> stream); @Override Chain<T> prependStream(Stream<? extends T> stream); @Override Chain<T> removeStream(Stream<? extends T> stream); @Override Chain<T> retainStream(Stream<? extends T> stream); @Override Chain<R> unitIterable(Iterable<R> it); @Override EmptyChain<T> emptyUnit(); @Override Chain<T> drop(long num); @Override Chain<T> take(long num); @Override NonEmptyChain<T> prepend(T value); abstract Chain<T> prependAll(Iterable< ? extends T> value); @Override NonEmptyChain<T> append(T value); @Override abstract Chain<T> appendAll(Iterable<? extends T> value); @Override Chain<T> reverse(); @Override abstract Option<T> get(int pos); @Override abstract T getOrElse(int pos, T alt); @Override abstract T getOrElseGet(int pos, Supplier<? extends T> alt); @Override abstract int size(); @Override ReactiveSeq<T> stream(); @Override Chain<T> filter(Predicate<? super T> fn); @Override abstract Chain<R> map(Function<? super T, ? extends R> fn); @Override Chain<R> flatMap(Function<? super T, ? extends ImmutableList<? extends R>> fn); @Override abstract R fold(Function<? super Some<T>, ? extends R> fn1, Function<? super None<T>, ? extends R> fn2); @Override abstract NonEmptyChain<T> onEmpty(T value); @Override abstract NonEmptyChain<T> onEmptyGet(Supplier<? extends T> supplier); @Override Chain<T> onEmptySwitch(Supplier<? extends ImmutableList<T>> supplier); @Override Chain<R> concatMap(Function<? super T, ? extends Iterable<? extends R>> mapper); @Override Chain<R> mergeMap(Function<? super T, ? extends Publisher<? extends R>> fn); @Override Chain<R> mergeMap(int maxConcurecy, Function<? super T, ? extends Publisher<? extends R>> fn); @Override Chain<T> replaceFirst(T currentElement, T newElement); @Override Chain<T> removeFirst(Predicate<? super T> pred); @Override Chain<T> subList(int start, int end); @Override Chain<U> ofType(Class<? extends U> type); @Override Chain<T> filterNot(Predicate<? super T> predicate); @Override Chain<T> notNull(); @Override Chain<T> peek(Consumer<? super T> c); @Override Chain<T> tailOrElse(ImmutableList<T> tail); @Override Chain<R> forEach4(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends Iterable<R2>> iterable2, Function3<? super T, ? super R1, ? super R2, ? extends Iterable<R3>> iterable3, Function4<? super T, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction); @Override Chain<R> forEach4(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends Iterable<R2>> iterable2, Function3<? super T, ? super R1, ? super R2, ? extends Iterable<R3>> iterable3, Function4<? super T, ? super R1, ? super R2, ? super R3, Boolean> filterFunction, Function4<? super T, ? super R1, ? super R2, ? super R3, ? extends R> yieldingFunction); @Override Chain<R> forEach3(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends Iterable<R2>> iterable2, Function3<? super T, ? super R1, ? super R2, ? extends R> yieldingFunction); @Override Chain<R> forEach3(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends Iterable<R2>> iterable2, Function3<? super T, ? super R1, ? super R2, Boolean> filterFunction, Function3<? super T, ? super R1, ? super R2, ? extends R> yieldingFunction); @Override Chain<R> forEach2(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction); @Override Chain<R> forEach2(Function<? super T, ? extends Iterable<R1>> iterable1, BiFunction<? super T, ? super R1, Boolean> filterFunction, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction); @Override Chain<T> removeAt(long pos); @Override Chain<T> removeAll(T... values); @Override Chain<T> retainAll(Iterable<? extends T> it); @Override Chain<T> retainAll(T... values); @Override Chain<ReactiveSeq<T>> permutations(); @Override Chain<ReactiveSeq<T>> combinations(int size); @Override Chain<ReactiveSeq<T>> combinations(); @Override Chain<R> zip(BiFunction<? super T, ? super T2, ? extends R> fn, Publisher<? extends T2> publisher); @Override Chain<Tuple2<T, U>> zipWithPublisher(Publisher<? extends U> other); @Override Chain<Tuple2<T, U>> zip(Iterable<? extends U> other); @Override Chain<R> zip3(Iterable<? extends S> second, Iterable<? extends U> third, Function3<? super T, ? super S, ? super U, ? extends R> fn3); @Override Chain<R> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth, Function4<? super T, ? super T2, ? super T3, ? super T4, ? extends R> fn); @Override Chain<T> combine(BiPredicate<? super T, ? super T> predicate, BinaryOperator<T> op); @Override Chain<T> combine(Monoid<T> op, BiPredicate<? super T, ? super T> predicate); @Override Chain<T> cycle(long times); @Override Chain<T> cycle(Monoid<T> m, long times); @Override Chain<T> cycleWhile(Predicate<? super T> predicate); @Override Chain<T> cycleUntil(Predicate<? super T> predicate); @Override Chain<R> zip(Iterable<? extends U> other, BiFunction<? super T, ? super U, ? extends R> zipper); @Override Chain<Tuple3<T, S, U>> zip3(Iterable<? extends S> second, Iterable<? extends U> third); @Override Chain<Tuple4<T, T2, T3, T4>> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth); @Override Chain<Tuple2<T, Long>> zipWithIndex(); @Override Chain<Seq<T>> sliding(int windowSize); @Override Chain<Seq<T>> sliding(int windowSize, int increment); @Override Chain<C> grouped(int size, Supplier<C> supplier); @Override Chain<Vector<T>> groupedUntil(Predicate<? super T> predicate); @Override Chain<Vector<T>> groupedUntil(BiPredicate<Vector<? super T>, ? super T> predicate); @Override Chain<Vector<T>> groupedWhile(Predicate<? super T> predicate); @Override Chain<C> groupedWhile(Predicate<? super T> predicate, Supplier<C> factory); @Override Chain<C> groupedUntil(Predicate<? super T> predicate, Supplier<C> factory); @Override Chain<Vector<T>> grouped(int groupSize); @Override Chain<T> distinct(); @Override Chain<T> scanLeft(Monoid<T> monoid); @Override Chain<U> scanLeft(U seed, BiFunction<? super U, ? super T, ? extends U> function); @Override Chain<T> scanRight(Monoid<T> monoid); @Override Chain<U> scanRight(U identity, BiFunction<? super T, ? super U, ? extends U> combiner); @Override Chain<T> sorted(); @Override Chain<T> sorted(Comparator<? super T> c); @Override Chain<T> takeWhile(Predicate<? super T> p); @Override Chain<T> dropWhile(Predicate<? super T> p); @Override Chain<T> takeUntil(Predicate<? super T> p); @Override Chain<T> dropUntil(Predicate<? super T> p); @Override Chain<T> dropRight(int num); @Override Chain<T> takeRight(int num); @Override Chain<T> intersperse(T value); @Override Chain<T> shuffle(); @Override Chain<T> shuffle(Random random); @Override Chain<T> slice(long from, long to); @Override Chain<T> sorted(Function<? super T, ? extends U> function); @Override NonEmptyChain<T> appendAll(T... values); @Override NonEmptyChain<T> prependAll(T... values); @Override Chain<T> insertAt(int pos, T... values); @Override Chain<T> deleteBetween(int start, int end); @Override Chain<T> plusAll(Iterable<? extends T> list); @Override NonEmptyChain<T> plus(T value); @Override Chain<T> removeValue(T value); @Override Chain<T> removeAll(Iterable<? extends T> value); @Override Chain<T> updateAt(int pos, T value); @Override Chain<T> insertAt(int pos, Iterable<? extends T> values); @Override Chain<T> insertAt(int i, T value); abstract Iterator<T> reverseIterator();  }