PriorityComparator.java

1
package fr.sii.ogham.core.util;
2
3
import java.util.Comparator;
4
import java.util.function.ToIntFunction;
5
6
/**
7
 * Comparator used to order objects. Higher priority will come first
8
 * 
9
 * @author Aurélien Baudet
10
 * @param <T>
11
 *            The type of compared object that contains a priority field
12
 *
13
 */
14
public class PriorityComparator<T> implements Comparator<T> {
15
	private final ToIntFunction<T> priorityAccessor;
16
17
	/**
18
	 * Initializes with the function used to access the priority attribute of
19
	 * the compared objects.
20
	 * 
21
	 * @param priorityAccessor
22
	 *            The function to get the priority value of compared objects
23
	 */
24
	public PriorityComparator(ToIntFunction<T> priorityAccessor) {
25
		super();
26
		this.priorityAccessor = priorityAccessor;
27
	}
28
29
	@Override
30
	public int compare(T o1, T o2) {
31 11 1. compare : removed negation → SURVIVED
2. compare : removed negation → NO_COVERAGE
3. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → SURVIVED
4. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → NO_COVERAGE
5. compare : removed negation → TIMED_OUT
6. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → TIMED_OUT
7. compare : removed negation → KILLED
8. compare : removed negation → KILLED
9. compare : removed negation → KILLED
10. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → KILLED
11. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → KILLED
		return -Integer.compare(priorityAccessor.applyAsInt(o1), priorityAccessor.applyAsInt(o2));
32
	}
33
34
}

Mutations

31

1.1
Location : compare
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
removed negation → KILLED

2.2
Location : compare
Killed by : none
removed negation → SURVIVED

3.3
Location : compare
Killed by : none
removed negation → NO_COVERAGE

4.4
Location : compare
Killed by : none
removed negation → TIMED_OUT

5.5
Location : compare
Killed by : oghamall.it.template.TemplateErrorTest.multiTemplateNotFound(oghamall.it.template.TemplateErrorTest)
removed negation → KILLED

6.6
Location : compare
Killed by : oghamcloudhopper.it.SpecialCharactersTest.gsm8bit(oghamcloudhopper.it.SpecialCharactersTest)
removed negation → KILLED

7.7
Location : compare
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → SURVIVED

8.8
Location : compare
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → TIMED_OUT

9.9
Location : compare
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → NO_COVERAGE

10.10
Location : compare
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → KILLED

11.11
Location : compare
Killed by : oghamcore.it.core.builder.TemplatePrioritySpec
replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM