Skip to content

Commit

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

/**
* Ctor.
Expand All @@ -77,7 +77,7 @@ public final class And implements Scalar<Boolean> {
* @param <X> Type of items in the iterable
*/
@SafeVarargs
public <X> And(final Func<X, Boolean> func, final X... src) {
public <X> And(final Func<? super X, Boolean> func, final X... src) {
this(func, new IterableOf<>(src));
}

Expand All @@ -88,7 +88,10 @@ public <X> And(final Func<X, Boolean> func, final X... src) {
* @param <X> Type of items in the iterable
* @since 0.24
*/
public <X> And(final Func<X, Boolean> func, final Iterable<X> src) {
public <X> And(
final Func<? super X, Boolean> func,
final Iterable<? extends X> src
) {
this(
new Mapped<>(
item -> new ScalarOf<>(() -> func.apply(item)),
Expand All @@ -105,7 +108,7 @@ public <X> And(final Func<X, Boolean> func, final Iterable<X> src) {
* @since 0.34
*/
@SafeVarargs
public <X> And(final X subject, final Func<X, Boolean>... conditions) {
public <X> And(final X subject, final Func<? super X, Boolean>... conditions) {
this(subject, new IterableOf<>(conditions));
}

Expand All @@ -116,7 +119,7 @@ public <X> And(final X subject, final Func<X, Boolean>... conditions) {
* @param <X> Type of items in the iterable
* @since 0.49
*/
public <X> And(final X subject, final Iterable<Func<X, Boolean>> conditions) {
public <X> And(final X subject, final Iterable<? extends Func<? super X, Boolean>> conditions) {
this(
new Mapped<>(
item -> new ScalarOf<>(() -> item.apply(subject)),
Expand All @@ -138,7 +141,7 @@ public And(final Scalar<Boolean>... scalar) {
* Ctor.
* @param iterable The iterable.
*/
public And(final Iterable<Scalar<Boolean>> iterable) {
public And(final Iterable<? extends Scalar<Boolean>> iterable) {
this.origin = iterable;
}

Expand Down

0 comments on commit bf76c56

Please sign in to comment.