Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterators: support transform() with JDK Function class #7302

Open
reschke opened this issue Jul 11, 2024 · 2 comments
Open

Iterators: support transform() with JDK Function class #7302

reschke opened this issue Jul 11, 2024 · 2 comments
Labels
P3 package=collect type=enhancement Make an existing feature better

Comments

@reschke
Copy link

reschke commented Jul 11, 2024

Currently:

https://guava.dev/releases/snapshot-jre/api/docs/com/google/common/collect/Iterators.html#transform(java.util.Iterator,com.google.common.base.Function)

...would be good to relax that to

transform(java.util.Iterator,java.util.function.Function)

so it becomes easier to migrate away from Guava Function class.

@cpovirk
Copy link
Member

cpovirk commented Jul 11, 2024

Thanks. We may do this eventually for at least some of our APIs. (previously: #2758)

Some things we'd want to consider:

  • We can't do this for our Android flavor until our Function extends the JDK Function there (as it already does in the JRE flavor). Otherwise, calls that pass lambdas would become ambiguous.
  • We discourage use of our transform and filter methods in favor of Stream nowadays. (We should really add a warning to Iterators similar to the one on https://guava.dev/Iterables.) It would be somewhat sad to make some of the discouraged methods in Iterators take up twice as much space in the Javadoc while leaving the handful that we still encourage alone.
  • Migrating is usually still relatively straightforward because you can use function::apply to adapt back and forth. Still, it's clearly true that it would be better not to have to :)

@cpovirk cpovirk added type=enhancement Make an existing feature better package=collect P3 labels Jul 11, 2024
@reschke
Copy link
Author

reschke commented Jul 12, 2024

Thanks for the pointers. That makes it indeed easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 package=collect type=enhancement Make an existing feature better
Projects
None yet
Development

No branches or pull requests

2 participants