1 | package com.github.dakusui.actionunit.actions; | |
2 | ||
3 | import com.github.dakusui.actionunit.core.Action; | |
4 | import com.github.dakusui.actionunit.core.Context; | |
5 | ||
6 | import java.util.Formatter; | |
7 | import java.util.function.Function; | |
8 | import java.util.stream.Stream; | |
9 | ||
10 | import static com.github.dakusui.actionunit.utils.InternalUtils.toStringIfOverriddenOrNoname; | |
11 | ||
12 | public interface ForEach<V> extends Contextful<Stream<V>> { | |
13 | @Override | |
14 | default void accept(Visitor visitor) { | |
15 |
1
1. accept : removed call to com/github/dakusui/actionunit/core/Action$Visitor::visit → KILLED |
visitor.visit(this); |
16 | } | |
17 | ||
18 | @Override | |
19 | default void formatTo(Formatter formatter, int flags, int width, int precision) { | |
20 | formatter.format("forEach:" + variableName() + ":" + toStringIfOverriddenOrNoname(valueSource())); | |
21 | } | |
22 | ||
23 | boolean isParallel(); | |
24 | ||
25 | class Builder<V> extends Contextful.Builder<Builder<V>, ForEach<V>, V, Stream<V>> { | |
26 | private boolean parallelism; | |
27 | ||
28 | public Builder(String variableName, Function<Context, Stream<V>> function) { | |
29 | super(variableName, function); | |
30 | this.sequentially(); | |
31 | } | |
32 | ||
33 | public Builder<V> parallely() { | |
34 |
1
1. parallely : replaced return value with null for com/github/dakusui/actionunit/actions/ForEach$Builder::parallely → KILLED |
return this.parallelism(true); |
35 | } | |
36 | ||
37 | public Builder<V> sequentially() { | |
38 |
1
1. sequentially : replaced return value with null for com/github/dakusui/actionunit/actions/ForEach$Builder::sequentially → KILLED |
return this.parallelism(false); |
39 | } | |
40 | ||
41 | public Builder<V> parallelism(boolean parallelism) { | |
42 | this.parallelism = parallelism; | |
43 |
1
1. parallelism : replaced return value with null for com/github/dakusui/actionunit/actions/ForEach$Builder::parallelism → KILLED |
return this; |
44 | } | |
45 | ||
46 | public ForEach<V> build() { | |
47 |
1
1. build : replaced return value with null for com/github/dakusui/actionunit/actions/ForEach$Builder::build → KILLED |
return new Impl<>(this.variableName(), this.internalVariableName(), this.valueSource(), this.parallelism, this.action()); |
48 | } | |
49 | ||
50 | private static class Impl<V> extends Contextful.Base<V, Stream<V>> implements ForEach<V> { | |
51 | private final boolean parallelism; | |
52 | ||
53 | public Impl(String variableName, String internalVariableName, Function<Context, Stream<V>> valueSource, boolean parallelism, Action action) { | |
54 | super(variableName, internalVariableName, valueSource, action); | |
55 | this.parallelism = parallelism; | |
56 | } | |
57 | ||
58 | @Override | |
59 | public boolean isParallel() { | |
60 |
2
1. isParallel : replaced boolean return with false for com/github/dakusui/actionunit/actions/ForEach$Builder$Impl::isParallel → SURVIVED 2. isParallel : replaced boolean return with true for com/github/dakusui/actionunit/actions/ForEach$Builder$Impl::isParallel → KILLED |
return this.parallelism; |
61 | } | |
62 | } | |
63 | } | |
64 | } | |
Mutations | ||
15 |
1.1 |
|
34 |
1.1 |
|
38 |
1.1 |
|
43 |
1.1 |
|
47 |
1.1 |
|
60 |
1.1 2.2 |