Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PhasesManagerImpl |
|
| 1.6666666666666667;1.667 |
1 | package org.jtheque.core.managers.lifecycle.phases; | |
2 | ||
3 | import java.util.Collection; | |
4 | import java.util.Queue; | |
5 | import java.util.concurrent.LinkedBlockingQueue; | |
6 | ||
7 | /* | |
8 | * This file is part of JTheque. | |
9 | * | |
10 | * JTheque is free software: you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation, either version 3 of the License. | |
13 | * | |
14 | * JTheque is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | /** | |
24 | * A phases manager implementation. | |
25 | * | |
26 | * @author Baptiste Wicht | |
27 | */ | |
28 | public final class PhasesManagerImpl implements IPhasesManager { | |
29 | private final Queue<LifeCyclePhase> phases; | |
30 | ||
31 | /** | |
32 | * Construct a new PhasesManagerImpl. | |
33 | * | |
34 | * @param phases The phases to manage. | |
35 | */ | |
36 | public PhasesManagerImpl(Collection<LifeCyclePhase> phases) { | |
37 | 0 | super(); |
38 | ||
39 | 0 | this.phases = new LinkedBlockingQueue<LifeCyclePhase>(phases); |
40 | 0 | } |
41 | ||
42 | @Override | |
43 | public void launchNextPhase() { | |
44 | 0 | if (phases.isEmpty()) { |
45 | 0 | throw new IllegalStateException("All the phases are launched !"); |
46 | } | |
47 | ||
48 | 0 | phases.poll().run(); |
49 | 0 | } |
50 | ||
51 | @Override | |
52 | public boolean isDone() { | |
53 | 0 | return phases.isEmpty(); |
54 | } | |
55 | } |