Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jul 20, 2022
2 parents 7baa2c7 + 78d621e commit fdca9c3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/list/Immutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public final class Immutable<T> implements List<T> {
/**
* Encapsulated list.
*/
private final List<T> list;
private final List<? extends T> list;

/**
* Ctor.
* @param src Source collection
*/
public Immutable(final List<T> src) {
public Immutable(final List<? extends T> src) {
this.list = src;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/list/ImmutableListIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public final class ImmutableListIterator<T> implements ListIterator<T> {
/**
* Original list iterator.
*/
private final ListIterator<T> origin;
private final ListIterator<? extends T> origin;

/**
* Ctor.
* @param iter Original list iterator.
*/
public ImmutableListIterator(final ListIterator<T> iter) {
public ImmutableListIterator(final ListIterator<? extends T> iter) {
this.origin = iter;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/list/Joined.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Joined(final X item, final List<? extends X> items) {
* Ctor.
* @param src Source lists
*/
public Joined(final Iterable<List<? extends X>> src) {
public Joined(final Iterable<? extends List<? extends X>> src) {
super(
new ListOf<>(src).stream()
.flatMap(List::stream)
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/cactoos/list/JoinedListIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class JoinedListIterator<T> implements ListIterator<T> {
/**
* {@link List} of {@link ListIterator}.
*/
private final List<ListIterator<T>> listiters;
private final List<? extends ListIterator<? extends T>> listiters;

/**
* Cursor of the {@link List} of {@link ListIterator}.
Expand All @@ -64,7 +64,7 @@ public final class JoinedListIterator<T> implements ListIterator<T> {
* @param items Items to concatenate
*/
@SafeVarargs
public JoinedListIterator(final ListIterator<T>... items) {
public JoinedListIterator(final ListIterator<? extends T>... items) {
this(new ListOf<>(items));
}

Expand All @@ -74,7 +74,7 @@ public JoinedListIterator(final ListIterator<T>... items) {
* @param items ListIterator
*/
@SuppressWarnings("unchecked")
public JoinedListIterator(final T item, final ListIterator<T> items) {
public JoinedListIterator(final T item, final ListIterator<? extends T> items) {
this(new ListOf<>(new ListOf<>(item).listIterator(), items));
}

Expand All @@ -84,15 +84,15 @@ public JoinedListIterator(final T item, final ListIterator<T> items) {
* @param item End item
*/
@SuppressWarnings("unchecked")
public JoinedListIterator(final ListIterator<T> items, final T item) {
public JoinedListIterator(final ListIterator<? extends T> items, final T item) {
this(new ListOf<>(items, new ListOf<>(item).listIterator()));
}

/**
* Ctor.
* @param items Items to concatenate
*/
public JoinedListIterator(final List<ListIterator<T>> items) {
public JoinedListIterator(final List<? extends ListIterator<? extends T>> items) {
this.listiters = items;
this.cursorlit = new AtomicInteger(-1);
this.cursor = new AtomicInteger(-1);
Expand Down Expand Up @@ -183,8 +183,8 @@ private boolean listHasPreviousElt() {
* Get current {@link ListIterator}.
* @return Current element
*/
private ListIterator<T> currentListIterator() {
final ListIterator<T> current;
private ListIterator<? extends T> currentListIterator() {
final ListIterator<? extends T> current;
if (this.cursorlit.get() == -1) {
current = Collections.emptyListIterator();
} else {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/cactoos/list/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@
* Lists, tests.
*
* @since 0.14
* @todo #1533:30min Exploit generic variance for package org.cactoos.list
* to ensure typing works as best as possible as it is explained in
* #1533 issue.
*/
package org.cactoos.list;
5 changes: 3 additions & 2 deletions src/test/java/org/cactoos/list/JoinedListIteratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void joinsListIterators() {
new Assertion<>(
"Must concatenate iterable of listIterators together",
new IterableOf<>(
new JoinedListIterator<>(
new JoinedListIterator<String>(
new ListOf<>("x").listIterator(),
new ListOf<>("y").listIterator()
)
Expand All @@ -60,7 +60,8 @@ void joinsListIterators() {
void navigatesInNonEmptyIterator() {
final ListIterator<Integer> joined = new JoinedListIterator<>(
new ListOf<>(1).listIterator(),
new ListOf<>(2).listIterator()
new ListOf<>(2).listIterator(),
new ListOf<>(3).listIterator()
);
new Assertion<>(
"Must call next method directly on non-empty listIterator for the first time",
Expand Down

0 comments on commit fdca9c3

Please sign in to comment.