TrimTree.java

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>By default it will use the depth as specified in the Program definition, but that can be overriden
13
 *
14
 */
15
@Value.Immutable
16
public interface TrimTree extends MutationPolicy {
17
18
	/**
19
	 * Override the max depth to enforce
20
	 * 
21
	 * @return
22
	 */
23
	@Value.Parameter
24
	@Value.Default
25
	public default Optional<Integer> maxDepth() {
26 1 1. maxDepth : removed call to java/util/Optional::empty → NO_COVERAGE
		return Optional.empty();
27
	}
28
29
	@Value.Check
30
	default void check() {
31
		maxDepth().ifPresent(maxDepth -> Validate.isTrue(maxDepth > 0));
32
	}
33
34
	/**
35
	 * Build a TrimTree enforcing a specific max depth
36
	 * 
37
	 * @param maxDepth
38
	 * @return
39
	 */
40
	public static TrimTree of(final int maxDepth) {
41 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));
42
	}
43
44
	/**
45
	 * Build a TrimTree using the default max depth as specified in the Program
46
	 * 
47
	 * @return
48
	 */
49
	public static TrimTree build() {
50 2 1. build : removed call to net/bmahe/genetics4j/gp/spec/mutation/ImmutableTrimTree::builder → NO_COVERAGE
2. build : replaced return value with null for net/bmahe/genetics4j/gp/spec/mutation/TrimTree::build → NO_COVERAGE
		return ImmutableTrimTree.builder()
51 1 1. build : removed call to net/bmahe/genetics4j/gp/spec/mutation/ImmutableTrimTree$Builder::build → NO_COVERAGE
				.build();
52
	}
53
}

Mutations

26

1.1
Location : maxDepth
Killed by : none
removed call to java/util/Optional::empty → NO_COVERAGE

41

1.1
Location : of
Killed by : none
replaced return value with null for net/bmahe/genetics4j/gp/spec/mutation/TrimTree::of → NO_COVERAGE

2.2
Location : of
Killed by : none
removed call to net/bmahe/genetics4j/gp/spec/mutation/ImmutableTrimTree::of → NO_COVERAGE

3.3
Location : of
Killed by : none
removed call to java/util/Optional::of → NO_COVERAGE

4.4
Location : of
Killed by : none
removed call to java/lang/Integer::valueOf → NO_COVERAGE

50

1.1
Location : build
Killed by : none
removed call to net/bmahe/genetics4j/gp/spec/mutation/ImmutableTrimTree::builder → NO_COVERAGE

2.2
Location : build
Killed by : none
replaced return value with null for net/bmahe/genetics4j/gp/spec/mutation/TrimTree::build → NO_COVERAGE

51

1.1
Location : build
Killed by : none
removed call to net/bmahe/genetics4j/gp/spec/mutation/ImmutableTrimTree$Builder::build → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.20.3