1 | package net.bmahe.genetics4j.gp.spec.mutation; | |
2 | ||
3 | import java.util.Optional; | |
4 | ||
5 | import org.apache.commons.lang3.Validate; | |
6 | import org.immutables.value.Value; | |
7 | ||
8 | import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy; | |
9 | ||
10 | /** | |
11 | * Ensure no tree will have a greater depth than allowed | |
12 | * <p> | |
13 | * By default it will use the depth as specified in the Program definition, but | |
14 | * that can be overriden | |
15 | * | |
16 | */ | |
17 | @Value.Immutable | |
18 | public interface TrimTree extends MutationPolicy { | |
19 | ||
20 | /** | |
21 | * Override the max depth to enforce | |
22 | * | |
23 | * @return | |
24 | */ | |
25 | @Value.Parameter | |
26 | @Value.Default | |
27 | public default Optional<Integer> maxDepth() { | |
28 |
1
1. maxDepth : removed call to java/util/Optional::empty → NO_COVERAGE |
return Optional.empty(); |
29 | } | |
30 | ||
31 | @Value.Check | |
32 | default void check() { | |
33 | maxDepth().ifPresent(maxDepth -> Validate.isTrue(maxDepth > 0)); | |
34 | } | |
35 | ||
36 | /** | |
37 | * Build a TrimTree enforcing a specific max depth | |
38 | * | |
39 | * @param maxDepth | |
40 | * @return | |
41 | */ | |
42 | public static TrimTree of(final int maxDepth) { | |
43 |
4
1. of : replaced return value with null for net/bmahe/genetics4j/gp/spec/mutation/TrimTree::of → NO_COVERAGE 2. of : removed call to net/bmahe/genetics4j/gp/spec/mutation/ImmutableTrimTree::of → NO_COVERAGE 3. of : removed call to java/util/Optional::of → NO_COVERAGE 4. of : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
return ImmutableTrimTree.of(Optional.of(maxDepth)); |
44 | } | |
45 | ||
46 | /** | |
47 | * Build a TrimTree using the default max depth as specified in the Program | |
48 | * | |
49 | * @return | |
50 | */ | |
51 | public static TrimTree build() { | |
52 |
3
1. build : replaced return value with null for net/bmahe/genetics4j/gp/spec/mutation/TrimTree::build → NO_COVERAGE 2. build : removed call to net/bmahe/genetics4j/gp/spec/mutation/ImmutableTrimTree$Builder::build → NO_COVERAGE 3. build : removed call to net/bmahe/genetics4j/gp/spec/mutation/ImmutableTrimTree::builder → NO_COVERAGE |
return ImmutableTrimTree.builder().build(); |
53 | } | |
54 | } | |
Mutations | ||
28 |
1.1 |
|
43 |
1.1 2.2 3.3 4.4 |
|
52 |
1.1 2.2 3.3 |