Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#1533) Generify org.cactoos.list package #1634

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 6 additions & 6 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<ListIterator<? extends T>> listiters;

/**
* Cursor of the {@link List} of {@link ListIterator}.
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<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
4 changes: 2 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 @@ -58,7 +58,7 @@ void joinsListIterators() {
@Test
@SuppressWarnings("unchecked")
void navigatesInNonEmptyIterator() {
final ListIterator<Integer> joined = new JoinedListIterator<>(
final ListIterator<Integer> joined = new JoinedListIterator<Integer>(
new ListOf<>(1).listIterator(),
new ListOf<>(2).listIterator()
);
Expand Down