diff options
author | Jonathan Bluett-Duncan <jbluettduncan@gmail.com> | 2020-10-13 10:55:23 -0700 |
---|---|---|
committer | Chris Povirk <cpovirk@google.com> | 2020-10-13 14:49:17 -0400 |
commit | e3dc2a7a0f3d89b595f6bb3b944bbe996e3824fe (patch) | |
tree | 3131c3a05e62376520bae8a8d46bd534cad7cfa8 /android | |
parent | 2ebf27fd45685e7f89bb4aae11e1709d49863717 (diff) | |
download | guava-e3dc2a7a0f3d89b595f6bb3b944bbe996e3824fe.tar.gz |
Fix example in documentation for `IteratorTester`
I made a mistake and accidentally included an example that does not
compile. Specifically, importing `KnownOrder` as-is does not compile;
instead one needs to import `IteratorTester.KnownOrder`. See #5254 for
more information.
I also changed the example to use `Collections#unmodifiableList`
rather than `ArrayList` because `ArrayList#iterator` does not satisfy
all the requirements of `IteratorFeature#MODIFIABLE`.
Fixes #5276
RELNOTES=n/a
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=336911192
Diffstat (limited to 'android')
-rw-r--r-- | android/guava-testlib/src/com/google/common/collect/testing/IteratorTester.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/IteratorTester.java b/android/guava-testlib/src/com/google/common/collect/testing/IteratorTester.java index 1e7f44647..111d337e1 100644 --- a/android/guava-testlib/src/com/google/common/collect/testing/IteratorTester.java +++ b/android/guava-testlib/src/com/google/common/collect/testing/IteratorTester.java @@ -50,19 +50,21 @@ import java.util.Iterator; * verify() method, which is called <em>after</em> each sequence and is guaranteed to be called * using the latest values obtained from {@link IteratorTester#newTargetIterator()}. * - * <p>For example, to test {@link java.util.ArrayList#iterator() ArrayList.iterator()}: + * <p>For example, to test {@link java.util.Collections#unmodifiableList(java.util.List) + * Collections.unmodifiableList}'s iterator: * * <pre>{@code * List<String> expectedElements = * Arrays.asList("a", "b", "c", "d", "e"); * List<String> actualElements = - * new ArrayList<>(Arrays.asList("a", "b", "c", "d", "e")); + * Collections.unmodifiableList( + * Arrays.asList("a", "b", "c", "d", "e")); * IteratorTester<String> iteratorTester = * new IteratorTester<String>( * 5, - * IteratorFeature.MODIFIABLE, + * IteratorFeature.UNMODIFIABLE, * expectedElements, - * KnownOrder.KNOWN_ORDER) { + * IteratorTester.KnownOrder.KNOWN_ORDER) { * @Override * protected Iterator<String> newTargetIterator() { * return actualElements.iterator(); @@ -72,6 +74,9 @@ import java.util.Iterator; * iteratorTester.testForEachRemaining(); * }</pre> * + * <p><b>Note</b>: It is necessary to use {@code IteratorTester.KnownOrder} as shown above, rather + * than {@code KnownOrder} directly, because otherwise the code is not compilable. + * * @author Kevin Bourrillion * @author Chris Povirk */ |