Skip to content

Commit b94bd32

Browse files
perceptron8Google Java Core Libraries
authored andcommitted
Update Javadoc with direct FluentIterable.{index,uniqueIndex} equivalents.
Also, update `FluentIterable` docs in `guava-android` to mention the `Stream`-related APIs that became part of `guava-android` in [Guava 33.4.0](https://github.com/google/guava/releases/tag/v33.4.0). This brings the docs closer to the corresponding `guava-jre` docs. Fixes google#3119 Fixes google#8007 RELNOTES=n/a PiperOrigin-RevId: 809166763
1 parent e9ea5a9 commit b94bd32

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

android/guava/src/com/google/common/collect/FluentIterable.java

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@
7777
* noted in the method descriptions below.
7878
* <li>Streams include primitive-specialized variants such as {@code IntStream}, the use of which
7979
* is strongly recommended.
80-
* <li>Streams are standard Java, not requiring a third-party dependency (but do render your code
81-
* incompatible with Java 7 and earlier).
80+
* <li>Streams are standard Java, not requiring a third-party dependency (but requiring <a
81+
* href="https://developer.android.com/studio/write/java8-support#library-desugaring">library
82+
* desugaring</a> or <a
83+
* href="https://developer.android.com/reference/java/util/stream/Stream">API Level 24</a>
84+
* under Android).
8285
* </ul>
8386
*
8487
* <h3>Example</h3>
@@ -137,8 +140,8 @@ private Iterable<E> getDelegate() {
137140
* Returns a fluent iterable that wraps {@code iterable}, or {@code iterable} itself if it is
138141
* already a {@code FluentIterable}.
139142
*
140-
* <p><b>{@code Stream} equivalent:</b> {@code iterable.stream()} if {@code iterable} is a {@link
141-
* Collection}; {@code StreamSupport.stream(iterable.spliterator(), false)} otherwise.
143+
* <p><b>{@code Stream} equivalent:</b> {@link Collection#stream} if {@code iterable} is a {@link
144+
* Collection}; {@link Streams#stream(Iterable)} otherwise.
142145
*/
143146
public static <E extends @Nullable Object> FluentIterable<E> from(Iterable<E> iterable) {
144147
return (iterable instanceof FluentIterable)
@@ -308,7 +311,7 @@ public Iterator<? extends T> get(int i) {
308311
/**
309312
* Returns a fluent iterable containing no elements.
310313
*
311-
* <p><b>{@code Stream} equivalent:</b> {@code Stream.empty()}.
314+
* <p><b>{@code Stream} equivalent:</b> {@link Stream#empty}.
312315
*
313316
* @since 20.0
314317
*/
@@ -345,7 +348,7 @@ public String toString() {
345348
/**
346349
* Returns the number of elements in this fluent iterable.
347350
*
348-
* <p><b>{@code Stream} equivalent:</b> {@code stream.count()}.
351+
* <p><b>{@code Stream} equivalent:</b> {@link Stream#count}.
349352
*/
350353
public final int size() {
351354
return Iterables.size(getDelegate());
@@ -614,8 +617,8 @@ public final boolean isEmpty() {
614617
* Returns an {@code ImmutableList} containing all of the elements from this fluent iterable in
615618
* proper sequence.
616619
*
617-
* <p><b>{@code Stream} equivalent:</b> {@code ImmutableList.copyOf(stream.iterator())}, or pass
618-
* {@link ImmutableList#toImmutableList} to {@code stream.collect()}.
620+
* <p><b>{@code Stream} equivalent:</b> pass {@link ImmutableList#toImmutableList} to {@code
621+
* stream.collect()}.
619622
*
620623
* @throws NullPointerException if any element is {@code null}
621624
* @since 14.0 (since 12.0 as {@code toImmutableList()}).
@@ -630,9 +633,8 @@ public final boolean isEmpty() {
630633
* FluentIterable} in the order specified by {@code comparator}. To produce an {@code
631634
* ImmutableList} sorted by its natural ordering, use {@code toSortedList(Ordering.natural())}.
632635
*
633-
* <p><b>{@code Stream} equivalent:</b> {@code
634-
* ImmutableList.copyOf(stream.sorted(comparator).iterator())}, or pass {@link
635-
* ImmutableList#toImmutableList} to {@code stream.sorted(comparator).collect()}.
636+
* <p><b>{@code Stream} equivalent:</b> pass {@link ImmutableList#toImmutableList} to {@code
637+
* stream.sorted(comparator).collect()}.
636638
*
637639
* @param comparator the function by which to sort list elements
638640
* @throws NullPointerException if any element of this iterable is {@code null}
@@ -647,8 +649,8 @@ public final boolean isEmpty() {
647649
* Returns an {@code ImmutableSet} containing all of the elements from this fluent iterable with
648650
* duplicates removed.
649651
*
650-
* <p><b>{@code Stream} equivalent:</b> {@code ImmutableSet.copyOf(stream.iterator())}, or pass
651-
* {@link ImmutableSet#toImmutableSet} to {@code stream.collect()}.
652+
* <p><b>{@code Stream} equivalent:</b> pass {@link ImmutableSet#toImmutableSet} to {@code
653+
* stream.collect()}.
652654
*
653655
* @throws NullPointerException if any element is {@code null}
654656
* @since 14.0 (since 12.0 as {@code toImmutableSet()}).
@@ -664,9 +666,8 @@ public final boolean isEmpty() {
664666
* {@code comparator.compare(x, y) == 0}) removed. To produce an {@code ImmutableSortedSet} sorted
665667
* by its natural ordering, use {@code toSortedSet(Ordering.natural())}.
666668
*
667-
* <p><b>{@code Stream} equivalent:</b> {@code ImmutableSortedSet.copyOf(comparator,
668-
* stream.iterator())}, or pass {@link ImmutableSortedSet#toImmutableSortedSet} to {@code
669-
* stream.collect()}.
669+
* <p><b>{@code Stream} equivalent:</b> pass {@link ImmutableSortedSet#toImmutableSortedSet} to
670+
* {@code stream.collect()}.
670671
*
671672
* @param comparator the function by which to sort set elements
672673
* @throws NullPointerException if any element of this iterable is {@code null}
@@ -680,8 +681,8 @@ public final boolean isEmpty() {
680681
/**
681682
* Returns an {@code ImmutableMultiset} containing all of the elements from this fluent iterable.
682683
*
683-
* <p><b>{@code Stream} equivalent:</b> {@code ImmutableMultiset.copyOf(stream.iterator())}, or
684-
* pass {@link ImmutableMultiset#toImmutableMultiset} to {@code stream.collect()}.
684+
* <p><b>{@code Stream} equivalent:</b> pass {@link ImmutableMultiset#toImmutableMultiset} to
685+
* {@code stream.collect()}.
685686
*
686687
* @throws NullPointerException if any element is null
687688
* @since 19.0
@@ -700,9 +701,8 @@ public final boolean isEmpty() {
700701
* {@code valueFunction} will be applied to more than one instance of that key and, if it is,
701702
* which result will be mapped to that key in the returned map.
702703
*
703-
* <p><b>{@code Stream} equivalent:</b> use {@code stream.collect(ImmutableMap.toImmutableMap(k ->
704-
* k, valueFunction))}. {@code ImmutableMap.copyOf(stream.collect(Collectors.toMap(k -> k,
705-
* valueFunction)))} behaves similarly, but may not preserve the order of entries.
704+
* <p><b>{@code Stream} equivalent:</b> {@code stream.collect(ImmutableMap.toImmutableMap(k -> k,
705+
* valueFunction))}.
706706
*
707707
* @throws NullPointerException if any element of this iterable is {@code null}, or if {@code
708708
* valueFunction} produces {@code null} for any key
@@ -722,9 +722,8 @@ public final boolean isEmpty() {
722722
* In the returned multimap, keys appear in the order they are first encountered, and the values
723723
* corresponding to each key appear in the same order as they are encountered.
724724
*
725-
* <p><b>{@code Stream} equivalent:</b> {@code stream.collect(Collectors.groupingBy(keyFunction))}
726-
* behaves similarly, but returns a mutable {@code Map<K, List<E>>} instead, and may not preserve
727-
* the order of entries.
725+
* <p><b>{@code Stream} equivalent:</b> {@code
726+
* stream.collect(ImmutableListMultimap.toImmutableListMultimap(keyFunction, v -> v))}.
728727
*
729728
* @param keyFunction the function used to produce the key for each value
730729
* @throws NullPointerException if any element of this iterable is {@code null}, or if {@code
@@ -754,10 +753,8 @@ public final boolean isEmpty() {
754753
* <p>If your index may associate multiple values with each key, use {@link #index(Function)
755754
* index}.
756755
*
757-
* <p><b>{@code Stream} equivalent:</b> use {@code
758-
* stream.collect(ImmutableMap.toImmutableMap(keyFunction, v -> v))}. {@code
759-
* ImmutableMap.copyOf(stream.collect(Collectors.toMap(keyFunction, v -> v)))}, but be aware that
760-
* this may not preserve the order of entries.
756+
* <p><b>{@code Stream} equivalent:</b> {@code
757+
* stream.collect(ImmutableMap.toImmutableMap(keyFunction, v -> v))}.
761758
*
762759
* @param keyFunction the function used to produce the key for each value
763760
* @return a map mapping the result of evaluating the function {@code keyFunction} on each value

guava/src/com/google/common/collect/FluentIterable.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,8 @@ public final boolean isEmpty() {
715715
* In the returned multimap, keys appear in the order they are first encountered, and the values
716716
* corresponding to each key appear in the same order as they are encountered.
717717
*
718-
* <p><b>{@code Stream} equivalent:</b> {@code stream.collect(Collectors.groupingBy(keyFunction))}
719-
* behaves similarly, but returns a mutable {@code Map<K, List<E>>} instead, and may not preserve
720-
* the order of entries.
718+
* <p><b>{@code Stream} equivalent:</b> {@code
719+
* stream.collect(ImmutableListMultimap.toImmutableListMultimap(keyFunction, v -> v))}.
721720
*
722721
* @param keyFunction the function used to produce the key for each value
723722
* @throws NullPointerException if any element of this iterable is {@code null}, or if {@code

0 commit comments

Comments
 (0)