Fix generics in IteratorChain.IteratorChain(Collection)

This commit is contained in:
Gary Gregory 2024-10-19 10:13:42 -04:00
parent 2d8ad42bde
commit 99f65a305e
3 changed files with 17 additions and 1 deletions

View File

@ -38,6 +38,7 @@
<action type="fix" dev="ggregory" due-to="Gary Gregory, Alex Herbert">BloomFilterExtractor.flatten() should throw an exception instead of returning null.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory, Claude Warren">Improve WrappedBloomFilterTest. All tests now assert copy() the same way.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory, Daniele" issue="COLLECTIONS-860">Javadoc CollectionBag.add* to throw ClassCastException.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix generics in IteratorChain.IteratorChain(Collection).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">LayerManager.Builder implements Supplier.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory, hemanth0525">Add CollectionUtils.duplicateList(Collection).</action>

View File

@ -97,7 +97,7 @@ public class IteratorChain<E> implements Iterator<E> {
* @throws ClassCastException if iterators collection doesn't contain an
* iterator
*/
public IteratorChain(final Collection<Iterator<? extends E>> iteratorChain) {
public IteratorChain(final Collection<? extends Iterator<? extends E>> iteratorChain) {
for (final Iterator<? extends E> iterator : iteratorChain) {
addIterator(iterator);
}

View File

@ -137,6 +137,21 @@ public class IteratorChainTest extends AbstractIteratorTest<String> {
}
}
@Test
public void testConstructList() {
final List<Iterator<String>> list = new ArrayList<>();
list.add(list1.iterator());
list.add(list2.iterator());
list.add(list3.iterator());
final List<String> expected = new ArrayList<>(list1);
expected.addAll(list2);
expected.addAll(list3);
final IteratorChain<String> iter = new IteratorChain<>(list);
final List<String> actual = new ArrayList<>();
iter.forEachRemaining(actual::add);
assertEquals(actual, expected);
}
@Test
@Override
public void testRemove() {