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 14 1. compare : removed negation → SURVIVED
2. compare : removed negation → SURVIVED
3. compare : removed negation → NO_COVERAGE
4. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → SURVIVED
5. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → SURVIVED
6. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → SURVIVED
7. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → NO_COVERAGE
8. compare : removed negation → TIMED_OUT
9. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → TIMED_OUT
10. compare : removed negation → KILLED
11. compare : removed negation → KILLED
12. compare : removed negation → KILLED
13. compare : replaced int return with 0 for fr/sii/ogham/core/util/PriorityComparator::compare → KILLED
14. 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 : oghamall.it.template.TemplateErrorTest.multiTemplateNotFound(oghamall.it.template.TemplateErrorTest)
removed negation → KILLED

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

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

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

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

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

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

8.8
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

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

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

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

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

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

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

Active mutators

Tests examined


Report generated by PIT OGHAM