8bitme / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

Lambda should properly collect objects that are iterables #83

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Lambda 2.3.3:

run this as JUnit test:

    class Foo {
        Bar getBar() {
            return new Bar();
        }
    }

    class Bar implements Iterable<String> {

        @Override
        public Iterator<String> iterator() {
            return java.util.Arrays.asList("A").iterator();
        }
    }

    @Test
    public void shouldCollectIterables() {
        List<Foo> foos = java.util.Arrays.asList(new Foo(), new Foo());
        List<Bar> bars = Lambda.collect(foos, Lambda.on(Foo.class).getBar());

        for (Object bar : bars) {
            Assert.assertEquals(Bar.class, bar.getClass());
        }
    }

Looks like lambda is going inside iterable if it's a result of collect method, 
which is unexpected.

Original issue reported on code.google.com by tomasz.b...@pragmatists.pl on 6 Feb 2012 at 10:57

GoogleCodeExporter commented 8 years ago
Fixed in lambdaj 2.4

Original comment by mario.fu...@gmail.com on 12 Feb 2012 at 11:45