Skip to content

Commit

Permalink
(yegor256#1533) Generify Joined
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryBarskov committed Apr 1, 2022
1 parent a5d14ba commit b7cbd17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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

0 comments on commit b7cbd17

Please sign in to comment.