maidh91 / guava-libraries

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

Iterables/Iterators.filter by type should take Class<? extends T> #485

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently the type signature of the method is:

<T> Iterables<T> filter(Iterables<?> unfiltered, Class<T> type)

Proposing to enhance this to:

<T> Iterables<T> filter(Iterables<?> unfiltered, Class<? extends T> type)

Similarly for Iterators.filter.

Original issue reported on code.google.com by yogy.nam...@gmail.com on 21 Nov 2010 at 7:41

GoogleCodeExporter commented 9 years ago
Our policy (which you'll notice we follow about 98% consistently) is to add 
wildcards or type parameters only as needed to allow the method to be invoked 
on any appropriate logically-correct inputs.  Additional wildcards like you 
suggest don't enable any new uses, only allow the user to tweak the result type 
to "pretend" that an Iterable<Foo> is really an Iterable<SuperFoo>.  Our policy 
is that if you want "pretending", you should just cast-and-suppress.

Original comment by kevinb@google.com on 2 Dec 2010 at 1:38

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