@@ -0,0 +1,2521 @@
+package net.emaze.dysfunctional.strings;%0A%0Aimport java.util.Iterator;%0Aimport java.util.List;%0Aimport net.emaze.dysfunctional.consumers.PipingConsumer;%0Aimport net.emaze.dysfunctional.contracts.dbc;%0Aimport net.emaze.dysfunctional.delegates.ToStringTransformer;%0Aimport net.emaze.dysfunctional.iterations.ConstantIterator;%0Aimport net.emaze.dysfunctional.iterations.Iterations;%0Aimport net.emaze.dysfunctional.iterations.StringOutputIterator;%0Aimport net.emaze.dysfunctional.multiplexing.InterposingIterator;%0A%0A/**%0A *%0A * @author rferranti%0A */%0Apublic abstract class Strings %7B%0A    %0A    public static %3CT%3E String join(Iterator%3CT%3E iterator)%7B%0A        final StringOutputIterator output = new StringOutputIterator();%0A        final PipingConsumer%3CString%3E pipe = new PipingConsumer%3CString%3E(output);%0A        final List%3CString%3E elements = Iterations.map(iterator, new ToStringTransformer%3CT%3E());%0A        return pipe.consume(elements.iterator()).toString();%0A    %7D%0A%0A%0A    public static %3CT,V%3E String interpose(Iterator%3CT%3E values, Iterator%3CV%3E separators)%7B%0A        dbc.precondition(values != null, %22calling interpose with a null values%22);%0A        dbc.precondition(separators != null, %22calling interpose with a null separators%22);%0A        %0A        final StringOutputIterator output = new StringOutputIterator();%0A        final PipingConsumer%3CString%3E pipe = new PipingConsumer%3CString%3E(output);%0A        final Iterator%3CString%3E input = new InterposingIterator%3CString%3E(%0A                Iterations.map(values, new ToStringTransformer%3CT%3E()).iterator(),%0A                //BUG: these map should be lazy (try using a constantIterator)%0A                Iterations.map(separators, new ToStringTransformer%3CV%3E()).iterator()%0A        );%0A        return pipe.consume(input).toString();%0A    %7D%0A%0A    public static %3CT,V%3E String interpose(Iterator%3CT%3E values, V separator)%7B%0A        dbc.precondition(values != null, %22calling interpose with a null values%22);%0A        dbc.precondition(separator != null, %22calling interpose with a null separator%22);%0A        %0A        final StringOutputIterator output = new StringOutputIterator();%0A        final PipingConsumer%3CString%3E pipe = new PipingConsumer%3CString%3E(output);%0A        final String separatorAsString = new ToStringTransformer%3CV%3E().perform(separator);%0A        final Iterator%3CString%3E input = new InterposingIterator%3CString%3E(%0A                Iterations.map(values, new ToStringTransformer%3CT%3E()).iterator(),%0A                new ConstantIterator%3CString%3E(separatorAsString)%0A        );%0A        return pipe.consume(input).toString();%0A    %7D%0A%7D%0A

Strings. implementation