mengdiwang / guava-libraries

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

Functional/Fluid Collection Handling #520

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I've done a simple prototype to implement a Queryable wrapper around the 
iterables to work with collections of data in a fluent and functional way.

For Example
With:
        List<TestElement> elements = ...;
        Predicate<TestElement> filter = new Predicate<TestElement>(){...};
        Function<TestElement> selector = new Function<TestElement,String>(){...};

One can use it:
        List<String> result =  Queryables.asQueryable(elements)
                                         .filter(filter)
                                         .transform(selector)
                                         .skip(10)
                                         .take(5)
                                         .toList();

A patch with my current state and tests is appended.
If it's usable, I can spend some more time in expanding it.
(Planned as next would be .orderBy()/.thenBy() support)

(PS: the toMap function from Issue 519 is used)

Original issue reported on code.google.com by nvoll...@gmail.com on 12 Jan 2011 at 5:49

Attachments:

GoogleCodeExporter commented 9 years ago
Attached the Java Source

Original comment by nvoll...@gmail.com on 12 Jan 2011 at 5:53

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks.  We actually already use a class like this internally, which we called 
FluentIterable, but we've never found a good name for it.  Queryable... doesn't 
convey much either.  See issue 11.

Original comment by kevinb@google.com on 12 Jan 2011 at 8:33

GoogleCodeExporter commented 9 years ago
Maybe your looking for http://code.google.com/p/functional-collections

Original comment by amer...@gmail.com on 12 Jan 2011 at 9:06

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09