Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Please explain why Lists doesn't have filter method #505
Original issue created by koppernickus on 2010-12-27 at 07:51 AM
I can see in idea graveyard that Lists.filter is one of rejected ideas. Could you please explain there why?
My motivation for Lists.filter is the need for transforming Iterable to List when using existing code requiring List as input. It would be more readable to use Lists.filter() instead of Lists.newArrayList(Collections2.filter())...
Original comment posted by neveue on 2010-12-30 at 11:45 PM
This was already discussed in the google-collections issues / group, but your question is legitimate since there is no mention of it in the guava project's issues / group ;)
Guava does not provide such a method, because the filtered List view would have very poor performance.
For these reasons, it is preferable to let the developer do the copy himself:
If you really want the syntactical sugar, and you know which implementation type you want to use in your project, you could create a static utility method that hides this boilerplate.
Original comment posted by neveue on 2010-12-31 at 12:15 AM
Woops, just saw the related thread in the Google Group. It seems like you already knew all of this...
Anyway, I'll link it here, since it's related:
Original comment posted by koppernickus on 2010-12-31 at 09:57 AM
Thanks for explanation, but what I really meant was explaining it on Wiki.