WithPriority.java

1
package fr.sii.ogham.core.util;
2
3
import java.util.Comparator;
4
5
/**
6
 * Helper class to register several objects with associated priority.
7
 * 
8
 * @author Aurélien Baudet
9
 *
10
 * @param <P>
11
 *            the type of priorized object
12
 * @see PriorizedList
13
 * @see PriorityComparator
14
 */
15
public class WithPriority<P> {
16
	private final P priorized;
17
	private final int priority;
18
19
	/**
20
	 * Wraps the priorized object with a priority.
21
	 * 
22
	 * @param priorized
23
	 *            the object to priorize
24
	 * @param priority
25
	 *            the associated priority
26
	 */
27
	public WithPriority(P priorized, int priority) {
28
		super();
29
		this.priorized = priorized;
30
		this.priority = priority;
31
	}
32
33
	public P getPriorized() {
34 1 1. getPriorized : replaced return value with null for fr/sii/ogham/core/util/WithPriority::getPriorized → RUN_ERROR
		return priorized;
35
	}
36
37
	public int getPriority() {
38 1 1. getPriority : replaced int return with 0 for fr/sii/ogham/core/util/WithPriority::getPriority → RUN_ERROR
		return priority;
39
	}
40
41
	@Override
42
	public String toString() {
43 1 1. toString : replaced return value with "" for fr/sii/ogham/core/util/WithPriority::toString → NO_COVERAGE
		return priorized + " (priority=" + priority + ")";
44
	}
45
46
	/**
47
	 * Provide a comparator used to sort by priority. Higher priority value
48
	 * first.
49
	 * 
50
	 * @param <P>
51
	 *            the type of priorized object
52
	 * @return the comparator
53
	 */
54
	public static <P> Comparator<WithPriority<P>> comparator() {
55 1 1. comparator : replaced return value with null for fr/sii/ogham/core/util/WithPriority::comparator → RUN_ERROR
		return new PriorityComparator<>(WithPriority::getPriority);
56
	}
57
}

Mutations

34

1.1
Location : getPriorized
Killed by :
replaced return value with null for fr/sii/ogham/core/util/WithPriority::getPriorized → RUN_ERROR

38

1.1
Location : getPriority
Killed by :
replaced int return with 0 for fr/sii/ogham/core/util/WithPriority::getPriority → RUN_ERROR

43

1.1
Location : toString
Killed by :
replaced return value with "" for fr/sii/ogham/core/util/WithPriority::toString → NO_COVERAGE

55

1.1
Location : comparator
Killed by :
replaced return value with null for fr/sii/ogham/core/util/WithPriority::comparator → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1