Package net.emaze.dysfunctional.output

Examples of net.emaze.dysfunctional.output.StringOutputIterator


    public static class Pipe {

        @Test
        public void canPipeFromIterator() {
            final Iterator<String> in = Iterations.iterator("1", "2", "3");
            final StringOutputIterator output = new StringOutputIterator();
            Consumers.pipe(in, output);
            Assert.assertEquals("123", output.toString());
        }
View Full Code Here


        }

        @Test
        public void canPipeFromIterable() {
            final Iterable<String> in = Iterations.iterable("1", "2", "3");
            final StringOutputIterator output = new StringOutputIterator();
            Consumers.pipe(in, output);
            Assert.assertEquals("123", output.toString());
        }
View Full Code Here

        }

        @Test
        public void canPipeFromArray() {
            final String[] in = new String[]{"1", "2", "3"};
            final StringOutputIterator output = new StringOutputIterator();
            Consumers.pipe(in, output);
            Assert.assertEquals("123", output.toString());
        }
View Full Code Here

public class ConsumeIntoOutputIteratorTest {

    @Test
    public void testThatCanConsume() {
        final List<String> input = Arrays.asList("1","2","3","4","5");
        final StringOutputIterator output = new StringOutputIterator();
        final ConsumeIntoOutputIterator<String> pipe = new ConsumeIntoOutputIterator<String>(output);
        pipe.perform(input.iterator());
        Assert.assertEquals("12345", output.toString());
    }
View Full Code Here

    }

    @Test
    public void testThatCanConsumeEmptyList() {
        final List<String> input = Arrays.<String>asList();
        final StringOutputIterator output = new StringOutputIterator();
        final ConsumeIntoOutputIterator<String> pipe = new ConsumeIntoOutputIterator<String>(output);
        pipe.perform(input.iterator());
        Assert.assertEquals("", output.toString());
    }
View Full Code Here

        Assert.assertEquals("", output.toString());
    }

    @Test(expected = IllegalArgumentException.class)
    public void consumingNullIteratorYieldException() {
        final StringOutputIterator output = new StringOutputIterator();
        new ConsumeIntoOutputIterator<String>(output).perform(null);
    }
View Full Code Here

        new ConsumeIntoOutputIterator<String>(null);
    }
   
    @Test(expected = ClassCastException.class)
    public void consumingFromErasureWithWrongTypeYieldsException() {
        final StringOutputIterator output = new StringOutputIterator();
        Delegate pipe = new ConsumeIntoOutputIterator(output);
        pipe.perform(new Object());
    }   
View Full Code Here

        dbc.precondition(values != null, "calling interpose with a null values");
        dbc.precondition(separators != null, "calling interpose with a null separators");
        final Iterator<String> input = new InterposingIterator<String>(
                new TransformingIterator<String, T>(values, new ToStringTransformer<T>()),
                new TransformingIterator<String, V>(separators, new ToStringTransformer<V>()));
        final StringOutputIterator output = new StringOutputIterator();
        final ConsumeIntoOutputIterator<String> pipe = new ConsumeIntoOutputIterator<String>(output);
        return pipe.perform(input).toString();
    }
View Full Code Here

public class JoinStrings<T> implements Delegate<String, Iterator<T>> {

    @Override
    public String perform(Iterator<T> iterator) {
        dbc.precondition(iterator != null, "cannot join a null iterator");
        final StringOutputIterator output = new StringOutputIterator();
        final ConsumeIntoOutputIterator<String> pipe = new ConsumeIntoOutputIterator<String>(output);
        final Iterator<String> elements = new TransformingIterator<String, T>(iterator, new ToStringTransformer<T>());
        return pipe.perform(elements).toString();
    }
View Full Code Here

TOP

Related Classes of net.emaze.dysfunctional.output.StringOutputIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.