Skip to content

Navigation Menu

Sign in
Sign up

Suggestion of Stream usage in Javadocs #8660

Open

Description

I wanted to give my perspective on the wording from helpers such as Lists.transform, namely the following:

* <p><b>Java 8+ users:</b> many use cases for this method are better addressed by {@link
* java.util.stream.Stream#map}. This method is not being deprecated, but we gently encourage you
* to migrate to streams.

I know it's a gentle suggestion to use Streams, but I still find Lists.transform and other lazy transformation methods superior for a lot of usage in the wild; for example, I often see a stream used to map to a target type, only to then be passed to an addAllFoo style method of a proto builder... which is just iterating and copying into another List. That sort of use case where you know it's a one shot iteration is generally more efficiently served via these Guava helpers from Lists, Collections2, Iterables, etc. No real action item here, just hoping that the Javadoc doesn't lead people to always reach for streams, as I find the Guava helpers still have their legitimate uses.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /