guava
guava copied to clipboard
Improve `Iterables` doc around migrating to `Stream`
We're seeing some evidence that people are interpreting the current text as "You should always choose Stream
over Iterables
" and even as "Iterables
is effectively deprecated."
I don't remember all the history, but at a minimum, I don't think we want to suggest "effectively deprecated," if only because of methods like mergeSorted
that don't have clean Stream
equivalents.
Even beyond that, I don't really see much wrong with getOnlyElement
.
(On the flip side, possibly we should document an equivalent to Iterables.toString
, which I think is fairly straightforward, even though it uses the 3-arg Collectors.joining
, which forces you to figure out the right order of arguments.)
The ongoing discussion on the linked issue reminds me of a couple other things:
- We should specifically warn people about
transform
and other lazily computed views. - We should note that
Streams.findLast
can be either faster than or slower thanIterables.getLast
.
We should also document Maps
, Sets
, Lists
, Multimaps
, Multisets
, Tables
, and Collections2
to warn about lazily computed views there.
There's also an interesting question about how much to prefer methods like uniqueIndex
over the Stream
equivalents. (There's some discussion of this in internal bug 213183492.)
what are the relevant files that I or another developer should add documentation in?