Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Oct 16, 2021
2 parents db8cb31 + 38b0cee commit 8f4efef
Show file tree
Hide file tree
Showing 23 changed files with 123 additions and 92 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
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
16 changes: 8 additions & 8 deletions src/main/java/org/cactoos/scalar/AndWithIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public final class AndWithIndex implements Scalar<Boolean> {
/**
* The iterator.
*/
private final Iterable<Func<Integer, Boolean>> iterable;
private final Iterable<? extends Func<Integer, Boolean>> iterable;

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

Expand All @@ -88,7 +88,7 @@ public <X> AndWithIndex(final Proc<X> proc, final X... src) {
* @param <X> Type of items in the iterable
*/
@SafeVarargs
public <X> AndWithIndex(final BiFunc<X, Integer, Boolean> func,
public <X> AndWithIndex(final BiFunc<? super X, Integer, Boolean> func,
final X... src) {
this(func, new IterableOf<>(src));
}
Expand All @@ -100,8 +100,8 @@ public <X> AndWithIndex(final BiFunc<X, Integer, Boolean> func,
* @param <X> Type of items in the iterable
* @since 0.24
*/
public <X> AndWithIndex(final BiProc<X, Integer> proc,
final Iterable<X> src) {
public <X> AndWithIndex(final BiProc<? super X, Integer> proc,
final Iterable<? extends X> src) {
this(new BiFuncOf<>(proc, true), src);
}

Expand All @@ -112,8 +112,8 @@ public <X> AndWithIndex(final BiProc<X, Integer> proc,
* @param <X> Type of items in the iterable
* @since 0.24
*/
public <X> AndWithIndex(final BiFunc<X, Integer, Boolean> func,
final Iterable<X> src) {
public <X> AndWithIndex(final BiFunc<? super X, Integer, Boolean> func,
final Iterable<? extends X> src) {
this(
new Mapped<>(
item -> new FuncOf<>(input -> func.apply(item, input)),
Expand All @@ -135,7 +135,7 @@ public AndWithIndex(final Func<Integer, Boolean>... src) {
* Ctor.
* @param src The iterable
*/
public AndWithIndex(final Iterable<Func<Integer, Boolean>> src) {
public AndWithIndex(final Iterable<? extends Func<Integer, Boolean>> src) {
this.iterable = src;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/scalar/CallableEnvelope.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public abstract class CallableEnvelope<T> implements Callable<T> {
/**
* Callable to decorate.
*/
private final Callable<T> origin;
private final Callable<? extends T> origin;

/**
* Ctor.
* @param callable The Callable
*/
public CallableEnvelope(final Callable<T> callable) {
public CallableEnvelope(final Callable<? extends T> callable) {
this.origin = callable;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/cactoos/scalar/EqualsNullable.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public final class EqualsNullable implements Scalar<Boolean> {
/**
* The first object for comparison.
*/
private final Scalar<Object> first;
private final Scalar<? extends Object> first;

/**
* The second object for comparison.
*/
private final Scalar<Object> second;
private final Scalar<? extends Object> second;

/**
* Accepts 2 objects to compare.
Expand All @@ -56,7 +56,7 @@ public EqualsNullable(final Object first, final Object second) {
* @param first Scalar to get value to compare
* @param second Object to compare with
*/
public EqualsNullable(final Scalar<Object> first, final Object second) {
public EqualsNullable(final Scalar<? extends Object> first, final Object second) {
this(first, () -> second);
}

Expand All @@ -65,7 +65,7 @@ public EqualsNullable(final Scalar<Object> first, final Object second) {
* @param first Object to compare
* @param second Scalar to get value to compare
*/
public EqualsNullable(final Object first, final Scalar<Object> second) {
public EqualsNullable(final Object first, final Scalar<? extends Object> second) {
this(() -> first, second);
}

Expand All @@ -74,8 +74,8 @@ public EqualsNullable(final Object first, final Scalar<Object> second) {
* @param first Scalar to get value to compare
* @param second Scalar to get value to compare with
*/
public EqualsNullable(final Scalar<Object> first,
final Scalar<Object> second) {
public EqualsNullable(final Scalar<? extends Object> first,
final Scalar<? extends Object> second) {
this.first = first;
this.second = second;
}
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/org/cactoos/scalar/FirstOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ public final class FirstOf<T> implements Scalar<T> {
/**
* Condition for getting the element.
*/
private final Func<T, Boolean> condition;
private final Func<? super T, Boolean> condition;

/**
* Source iterable.
*/
private final Iterable<T> source;
private final Iterable<? extends T> source;

/**
* Fallback used if no value matches.
*/
private final Scalar<T> fallback;
private final Scalar<? extends T> fallback;

/**
* Constructor with default condition (always `true`) and plain fallback.
* @param src Source iterable
* @param fbck Fallback used if no value matches
*/
public FirstOf(final Iterable<T> src, final T fbck) {
public FirstOf(final Iterable<? extends T> src, final T fbck) {
this(
new FuncOf<>(new True()),
src,
Expand All @@ -71,7 +71,7 @@ public FirstOf(final Iterable<T> src, final T fbck) {
* @param src Source iterable
* @param fbck Fallback used if no value matches
*/
public FirstOf(final Iterable<T> src, final Scalar<T> fbck) {
public FirstOf(final Iterable<? extends T> src, final Scalar<? extends T> fbck) {
this(
new FuncOf<>(new True()),
src,
Expand All @@ -85,8 +85,11 @@ public FirstOf(final Iterable<T> src, final Scalar<T> fbck) {
* @param src Source iterable
* @param fbck Fallback used if no value matches
*/
public FirstOf(final Func<T, Boolean> cond, final Iterable<T> src,
final Scalar<T> fbck) {
public FirstOf(
final Func<? super T, Boolean> cond,
final Iterable<? extends T> src,
final Scalar<? extends T> fbck
) {
this.condition = cond;
this.source = src;
this.fallback = fbck;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/scalar/IoChecked.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public final class IoChecked<T> implements Scalar<T> {
/**
* Original scalar.
*/
private final Scalar<T> origin;
private final Scalar<? extends T> origin;

/**
* Ctor.
* @param scalar Encapsulated scalar
*/
public IoChecked(final Scalar<T> scalar) {
public IoChecked(final Scalar<? extends T> scalar) {
this.origin = scalar;
}

Expand Down
Loading

2 comments on commit 8f4efef

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 8f4efef Oct 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1533-c35e3786 disappeared from src/main/java/org/cactoos/scalar/package-info.java, that's why I closed #1569. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 8f4efef Oct 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1569-7739be3c discovered in src/main/java/org/cactoos/scalar/package-info.java and submitted as #1630. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.