SinglePointArithmeticCombinationHandler.java

1
package net.bmahe.genetics4j.core.combination.singlepointarithmetic;
2
3
import java.util.random.RandomGenerator;
4
5
import org.apache.commons.lang3.Validate;
6
7
import net.bmahe.genetics4j.core.combination.ChromosomeCombinator;
8
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorHandler;
9
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorResolver;
10
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
11
import net.bmahe.genetics4j.core.spec.chromosome.DoubleChromosomeSpec;
12
import net.bmahe.genetics4j.core.spec.chromosome.FloatChromosomeSpec;
13
import net.bmahe.genetics4j.core.spec.chromosome.IntChromosomeSpec;
14
import net.bmahe.genetics4j.core.spec.combination.CombinationPolicy;
15
import net.bmahe.genetics4j.core.spec.combination.SinglePointArithmetic;
16
17
public class SinglePointArithmeticCombinationHandler<T extends Comparable<T>> implements ChromosomeCombinatorHandler<T> {
18
19
	private final RandomGenerator randomGenerator;
20
21
	public SinglePointArithmeticCombinationHandler(final RandomGenerator _randomGenerator) {
22
		Validate.notNull(_randomGenerator);
23
24 1 1. <init> : Removed assignment to member variable randomGenerator → SURVIVED
		this.randomGenerator = _randomGenerator;
25
	}
26
27
	@Override
28
	public boolean canHandle(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
29
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) {
30
		Validate.notNull(chromosomeCombinatorResolver);
31
		Validate.notNull(combinationPolicy);
32
		Validate.notNull(chromosome);
33
34 15 1. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::canHandle → NO_COVERAGE
3. canHandle : negated conditional → NO_COVERAGE
4. canHandle : negated conditional → NO_COVERAGE
5. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
6. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
7. canHandle : Substituted 1 with 0 → NO_COVERAGE
8. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
9. canHandle : negated conditional → NO_COVERAGE
10. canHandle : Substituted 0 with 1 → NO_COVERAGE
11. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
12. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
13. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
14. canHandle : negated conditional → NO_COVERAGE
15. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
		return combinationPolicy instanceof SinglePointArithmetic && (chromosome instanceof IntChromosomeSpec
35
				|| chromosome instanceof DoubleChromosomeSpec || chromosome instanceof FloatChromosomeSpec);
36
	}
37
38
	@Override
39
	public ChromosomeCombinator<T> resolve(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
40
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) {
41
		Validate.notNull(chromosomeCombinatorResolver);
42
		Validate.notNull(combinationPolicy);
43
		Validate.notNull(chromosome);
44
		Validate.isInstanceOf(SinglePointArithmetic.class, combinationPolicy);
45
46
		final var singlePointArithmeticRecombination = (SinglePointArithmetic) combinationPolicy;
47 1 1. resolve : removed call to net/bmahe/genetics4j/core/spec/combination/SinglePointArithmetic::alpha → NO_COVERAGE
		final double alpha = singlePointArithmeticRecombination.alpha();
48
49 3 1. resolve : negated conditional → NO_COVERAGE
2. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
3. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
		if (chromosome instanceof IntChromosomeSpec) {
50 2 1. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/IntChromosomeSinglePointArithmetic::<init> → NO_COVERAGE
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE
			return new IntChromosomeSinglePointArithmetic<T>(randomGenerator, alpha);
51
		}
52
53 3 1. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
2. resolve : negated conditional → NO_COVERAGE
3. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
		if (chromosome instanceof DoubleChromosomeSpec) {
54 2 1. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE
2. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/DoubleChromosomeSinglePointArithmetic::<init> → NO_COVERAGE
			return new DoubleChromosomeSinglePointArithmetic<T>(randomGenerator, alpha);
55
		}
56
57 3 1. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
2. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
3. resolve : negated conditional → NO_COVERAGE
		if (chromosome instanceof FloatChromosomeSpec) {
58 2 1. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/FloatChromosomeSinglePointArithmetic::<init> → NO_COVERAGE
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE
			return new FloatChromosomeSinglePointArithmetic<T>(randomGenerator, (float) alpha);
59
		}
60
61 2 1. resolve : removed call to java/lang/String::valueOf → NO_COVERAGE
2. resolve : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE
		throw new IllegalArgumentException("Could not handle chromosome " + chromosome);
62
	}
63
}

Mutations

24

1.1
Location : <init>
Killed by : none
Removed assignment to member variable randomGenerator → SURVIVED
Covering tests

34

1.1
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

2.2
Location : canHandle
Killed by : none
replaced boolean return with true for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::canHandle → NO_COVERAGE

3.3
Location : canHandle
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : canHandle
Killed by : none
negated conditional → NO_COVERAGE

5.5
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

6.6
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

7.7
Location : canHandle
Killed by : none
Substituted 1 with 0 → NO_COVERAGE

8.8
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

9.9
Location : canHandle
Killed by : none
negated conditional → NO_COVERAGE

10.10
Location : canHandle
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

11.11
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

12.12
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

13.13
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

14.14
Location : canHandle
Killed by : none
negated conditional → NO_COVERAGE

15.15
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

47

1.1
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/combination/SinglePointArithmetic::alpha → NO_COVERAGE

49

1.1
Location : resolve
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : resolve
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

3.3
Location : resolve
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

50

1.1
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/IntChromosomeSinglePointArithmetic::<init> → NO_COVERAGE

2.2
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE

53

1.1
Location : resolve
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

2.2
Location : resolve
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : resolve
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

54

1.1
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE

2.2
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/DoubleChromosomeSinglePointArithmetic::<init> → NO_COVERAGE

57

1.1
Location : resolve
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

2.2
Location : resolve
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

3.3
Location : resolve
Killed by : none
negated conditional → NO_COVERAGE

58

1.1
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/FloatChromosomeSinglePointArithmetic::<init> → NO_COVERAGE

2.2
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE

61

1.1
Location : resolve
Killed by : none
removed call to java/lang/String::valueOf → NO_COVERAGE

2.2
Location : resolve
Killed by : none
removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.6