FloatChromosomeFactory.java

1
package net.bmahe.genetics4j.core.chromosomes.factory;
2
3
import java.util.Objects;
4
import java.util.function.Supplier;
5
import java.util.random.RandomGenerator;
6
7
import org.apache.commons.lang3.Validate;
8
9
import net.bmahe.genetics4j.core.chromosomes.FloatChromosome;
10
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
11
import net.bmahe.genetics4j.core.spec.chromosome.FloatChromosomeSpec;
12
import net.bmahe.genetics4j.core.util.DistributionUtils;
13
14
public class FloatChromosomeFactory implements ChromosomeFactory<FloatChromosome> {
15
16
	private final RandomGenerator randomGenerator;
17
18
	public FloatChromosomeFactory(final RandomGenerator _randomGenerator) {
19
		Objects.requireNonNull(_randomGenerator);
20
21 1 1. <init> : Removed assignment to member variable randomGenerator → KILLED
		this.randomGenerator = _randomGenerator;
22
	}
23
24
	@Override
25
	public boolean canHandle(final ChromosomeSpec chromosomeSpec) {
26
		Objects.requireNonNull(chromosomeSpec);
27
28 2 1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::canHandle → KILLED
2. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::canHandle → KILLED
		return chromosomeSpec instanceof FloatChromosomeSpec;
29
	}
30
31
	@Override
32
	public FloatChromosome generate(final ChromosomeSpec chromosomeSpec) {
33
		Objects.requireNonNull(chromosomeSpec);
34
		Validate.isInstanceOf(FloatChromosomeSpec.class, chromosomeSpec);
35
36
		final FloatChromosomeSpec floatChromosomeSpec = (FloatChromosomeSpec) chromosomeSpec;
37
38 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::minValue → KILLED
		final var minValue = floatChromosomeSpec.minValue();
39 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::maxValue → KILLED
		final var maxValue = floatChromosomeSpec.maxValue();
40 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::distribution → KILLED
		final var distribution = floatChromosomeSpec.distribution();
41
42
		final Supplier<Float> generator = DistributionUtils
43 1 1. generate : removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionFloatValueSupplier → KILLED
				.distributionFloatValueSupplier(randomGenerator, minValue, maxValue, distribution);
44
45 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED
		float[] values = new float[floatChromosomeSpec.size()];
46 6 1. generate : Substituted 0 with 1 → KILLED
2. generate : removed conditional - replaced comparison check with false → KILLED
3. generate : negated conditional → KILLED
4. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED
5. generate : removed conditional - replaced comparison check with true → KILLED
6. generate : changed conditional boundary → KILLED
		for (int i = 0; i < floatChromosomeSpec.size(); i++) {
47 2 1. generate : removed call to java/lang/Float::floatValue → KILLED
2. generate : removed call to java/util/function/Supplier::get → KILLED
			values[i] = generator.get();
48
		}
49
50 2 1. generate : replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::generate → KILLED
2. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED
		return new FloatChromosome(floatChromosomeSpec.size(),
51 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::minValue → SURVIVED
				floatChromosomeSpec.minValue(),
52 2 1. generate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::<init> → KILLED
2. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::maxValue → KILLED
				floatChromosomeSpec.maxValue(),
53
				values);
54
	}
55
}

Mutations

21

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
Removed assignment to member variable randomGenerator → KILLED

28

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:canHandleTest()]
replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::canHandle → KILLED

2.2
Location : canHandle
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:canHandleTest()]
replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::canHandle → KILLED

38

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::minValue → KILLED

39

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::maxValue → KILLED

40

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::distribution → KILLED

43

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionFloatValueSupplier → KILLED

45

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED

46

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
Substituted 0 with 1 → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed conditional - replaced comparison check with false → KILLED

3.3
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
negated conditional → KILLED

4.4
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED

5.5
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed conditional - replaced comparison check with true → KILLED

6.6
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
changed conditional boundary → KILLED

47

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to java/lang/Float::floatValue → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to java/util/function/Supplier::get → KILLED

50

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::generate → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED

51

1.1
Location : generate
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::minValue → SURVIVED
Covering tests

52

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::<init> → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::maxValue → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.7 support