Skip to content

Commit

Permalink
(yegor256#1445) Remove casts where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel committed Jan 10, 2021
1 parent 896cf00 commit f34f64b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/cactoos/scalar/And.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public <X> And(final Func<X, Boolean> func, final X... src) {
public <X> And(final Func<X, Boolean> func, final Iterable<X> src) {
this(
new Mapped<>(
item -> (Scalar<Boolean>) () -> func.apply(item), src
item -> new ScalarOf<>(() -> func.apply(item)),
src
)
);
}
Expand All @@ -118,7 +119,7 @@ public <X> And(final X subject, final Func<X, Boolean>... conditions) {
public <X> And(final X subject, final Iterable<Func<X, Boolean>> conditions) {
this(
new Mapped<>(
item -> (Scalar<Boolean>) () -> item.apply(subject),
item -> new ScalarOf<>(() -> item.apply(subject)),
conditions
)
);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/cactoos/scalar/AndInThreads.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public <X> AndInThreads(final Func<X, Boolean> func,
final Iterable<X> src) {
this(
new Mapped<>(
item -> (Scalar<Boolean>) () -> func.apply(item), src
item -> new ScalarOf<>(() -> func.apply(item)),
src
)
);
}
Expand Down Expand Up @@ -164,7 +165,8 @@ public <X> AndInThreads(final ExecutorService svc,
this(
svc,
new Mapped<>(
item -> (Scalar<Boolean>) () -> func.apply(item), src
item -> new ScalarOf<>(() -> func.apply(item)),
src
)
);
}
Expand Down Expand Up @@ -210,7 +212,7 @@ public Boolean value() throws Exception {
futures.add(this.service.submit(item::value));
}
final boolean result = new And(
(Func<Future<Boolean>, Boolean>) Future::get,
Future::get,
futures
).value();
if (this.shut) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/cactoos/scalar/AndWithIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.cactoos.Proc;
import org.cactoos.Scalar;
import org.cactoos.func.BiFuncOf;
import org.cactoos.func.FuncOf;
import org.cactoos.iterable.IterableOf;
import org.cactoos.iterable.Mapped;

Expand Down Expand Up @@ -115,8 +116,8 @@ public <X> AndWithIndex(final BiFunc<X, Integer, Boolean> func,
final Iterable<X> src) {
this(
new Mapped<>(
item -> (Func<Integer, Boolean>) input
-> func.apply(item, input), src
item -> new FuncOf<>(input -> func.apply(item, input)),
src
)
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/cactoos/scalar/Or.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public <X> Or(final Proc<X> proc, final Iterable<X> src) {
public <X> Or(final Func<X, Boolean> func, final Iterable<X> src) {
this(
new Mapped<>(
item -> (Scalar<Boolean>) () -> func.apply(item), src
item -> new ScalarOf<>(() -> func.apply(item)),
src
)
);
}
Expand All @@ -140,7 +141,7 @@ public <X> Or(final Func<X, Boolean> func, final Iterable<X> src) {
public <X> Or(final X subject, final Func<X, Boolean>... conditions) {
this(
new Mapped<>(
item -> (Scalar<Boolean>) () -> item.apply(subject),
item -> new ScalarOf<>(() -> item.apply(subject)),
new IterableOf<>(conditions)
)
);
Expand Down

0 comments on commit f34f64b

Please sign in to comment.