1 | package fr.sii.ogham.core.builder.priority; | |
2 | ||
3 | import java.util.concurrent.atomic.AtomicInteger; | |
4 | ||
5 | /** | |
6 | * Provides a priority based on a decrement. It decrements so the first source | |
7 | * has higher priority than the next one. | |
8 | * | |
9 | * <p> | |
10 | * The decrement starts at {@code initialValue} (0 by default) and decrements. | |
11 | * | |
12 | * @author Aurélien Baudet | |
13 | * | |
14 | * @param <T> | |
15 | * the type of the source | |
16 | */ | |
17 | public class AutoDecrementPriorityProvider<T> implements PriorityProvider<T> { | |
18 | private final AtomicInteger increment; | |
19 | ||
20 | /** | |
21 | * Initializes the decrement with {@code initialValue} set to 0. | |
22 | */ | |
23 | public AutoDecrementPriorityProvider() { | |
24 | this(0); | |
25 | } | |
26 | ||
27 | /** | |
28 | * Initializes with the provided initial value. | |
29 | * | |
30 | * @param initialValue | |
31 | * the initial value | |
32 | */ | |
33 | public AutoDecrementPriorityProvider(int initialValue) { | |
34 | this(new AtomicInteger(initialValue)); | |
35 | } | |
36 | ||
37 | private AutoDecrementPriorityProvider(AtomicInteger increment) { | |
38 | super(); | |
39 | this.increment = increment; | |
40 | } | |
41 | ||
42 | @Override | |
43 | public int provide(T source) { | |
44 |
2
1. provide : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AutoDecrementPriorityProvider::provide → SURVIVED 2. provide : replaced int return with 0 for fr/sii/ogham/core/builder/priority/AutoDecrementPriorityProvider::provide → NO_COVERAGE |
return increment.decrementAndGet(); |
45 | } | |
46 | ||
47 | } | |
Mutations | ||
44 |
1.1 2.2 |