Skip to content

Commit

Permalink
(yegor256#1569) Added wildcards in AndInThreads ctors.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocket-3 committed Sep 12, 2021
1 parent bf76c56 commit 43adab5
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions src/main/java/org/cactoos/scalar/AndInThreads.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public final class AndInThreads implements Scalar<Boolean> {
/**
* The iterator.
*/
private final Iterable<Scalar<Boolean>> iterable;
private final Iterable<? extends Scalar<Boolean>> iterable;

/**
* Shut down the service when it's done.
Expand All @@ -78,7 +78,7 @@ public final class AndInThreads implements Scalar<Boolean> {
* @param <X> Type of items in the iterable
*/
@SafeVarargs
public <X> AndInThreads(final Func<X, Boolean> func, final X... src) {
public <X> AndInThreads(final Func<? super X, Boolean> func, final X... src) {
this(func, new IterableOf<>(src));
}

Expand All @@ -88,8 +88,8 @@ public <X> AndInThreads(final Func<X, Boolean> func, final X... src) {
* @param src The iterable
* @param <X> Type of items in the iterable
*/
public <X> AndInThreads(final Func<X, Boolean> func,
final Iterable<X> src) {
public <X> AndInThreads(final Func<? super X, Boolean> func,
final Iterable<? extends X> src) {
this(
new Mapped<>(
item -> new ScalarOf<>(() -> func.apply(item)),
Expand All @@ -111,7 +111,7 @@ public AndInThreads(final Scalar<Boolean>... src) {
* Ctor.
* @param src The iterable
*/
public AndInThreads(final Iterable<Scalar<Boolean>> src) {
public AndInThreads(final Iterable<? extends Scalar<Boolean>> src) {
this(Executors.newCachedThreadPool(), src, true);
}

Expand All @@ -123,8 +123,11 @@ public AndInThreads(final Iterable<Scalar<Boolean>> src) {
* @param <X> Type of items in the iterable
*/
@SafeVarargs
public <X> AndInThreads(final ExecutorService svc,
final Proc<X> proc, final X... src) {
public <X> AndInThreads(
final ExecutorService svc,
final Proc<? super X> proc,
final X... src
) {
this(svc, new FuncOf<>(proc, true), src);
}

Expand All @@ -136,8 +139,11 @@ public <X> AndInThreads(final ExecutorService svc,
* @param <X> Type of items in the iterable
*/
@SafeVarargs
public <X> AndInThreads(final ExecutorService svc,
final Func<X, Boolean> func, final X... src) {
public <X> AndInThreads(
final ExecutorService svc,
final Func<? super X, Boolean> func,
final X... src
) {
this(svc, func, new IterableOf<>(src));
}

Expand All @@ -148,8 +154,11 @@ public <X> AndInThreads(final ExecutorService svc,
* @param src The iterable
* @param <X> Type of items in the iterable
*/
public <X> AndInThreads(final ExecutorService svc,
final Proc<X> proc, final Iterable<X> src) {
public <X> AndInThreads(
final ExecutorService svc,
final Proc<? super X> proc,
final Iterable<? extends X> src
) {
this(svc, new FuncOf<>(proc, true), src);
}

Expand All @@ -160,8 +169,11 @@ public <X> AndInThreads(final ExecutorService svc,
* @param src The iterable
* @param <X> Type of items in the iterable
*/
public <X> AndInThreads(final ExecutorService svc,
final Func<X, Boolean> func, final Iterable<X> src) {
public <X> AndInThreads(
final ExecutorService svc,
final Func<? super X, Boolean> func,
final Iterable<? extends X> src
) {
this(
svc,
new Mapped<>(
Expand All @@ -188,7 +200,7 @@ public AndInThreads(final ExecutorService svc,
* @param src The iterable
*/
public AndInThreads(final ExecutorService svc,
final Iterable<Scalar<Boolean>> src) {
final Iterable<? extends Scalar<Boolean>> src) {
this(svc, src, false);
}

Expand All @@ -199,7 +211,7 @@ public AndInThreads(final ExecutorService svc,
* @param sht Shut it down
*/
private AndInThreads(final ExecutorService svc,
final Iterable<Scalar<Boolean>> src, final boolean sht) {
final Iterable<? extends Scalar<Boolean>> src, final boolean sht) {
this.service = svc;
this.iterable = src;
this.shut = sht;
Expand Down

0 comments on commit 43adab5

Please sign in to comment.