Skip to content

Commit

Permalink
(yegor256#1169) Wild-cards for parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoss committed Sep 29, 2020
1 parent 48f35c0 commit 5e7d43d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/cactoos/list/Joined.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class Joined<X> extends ListEnvelope<X> {
* @param src Source lists
*/
@SafeVarargs
public Joined(final List<X>... src) {
public Joined(final List<? extends X>... src) {
this(new IterableOf<>(src));
}

Expand All @@ -53,15 +53,15 @@ public Joined(final List<X>... src) {
* @since 0.32
*/
@SuppressWarnings("unchecked")
public Joined(final X item, final List<X> items) {
public Joined(final X item, final List<? extends X> items) {
this(new ListOf<>(item), items);
}

/**
* Ctor.
* @param src Source lists
*/
public Joined(final Iterable<List<X>> src) {
public Joined(final Iterable<List<? extends X>> src) {
super(
new ListOf<>(src).stream()
.flatMap(List::stream)
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/cactoos/list/ListOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ public final class ListOf<T> extends ListEnvelope<T> {
* Ctor.
*
* @param array An array of some elements
* @param <Z> Sub-type of T
*/
@SafeVarargs
public ListOf(final T... array) {
public <Z extends T> ListOf(final Z... array) {
this(new IterableOf<>(array));
}

Expand All @@ -52,15 +53,15 @@ public ListOf(final T... array) {
* @param src An {@link Iterator}
* @since 0.21
*/
public ListOf(final Iterator<T> src) {
this(() -> src);
public ListOf(final Iterator<? extends T> src) {
this(new IterableOf<T>(src));
}

/**
* Ctor.
* @param src An {@link Iterable}
*/
public ListOf(final Iterable<T> src) {
public ListOf(final Iterable<? extends T> src) {
super(new LinkedList<>());
src.forEach(super::add);
}
Expand Down

0 comments on commit 5e7d43d

Please sign in to comment.