Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
IStateManager |
|
| 1.0;1 |
1 | package org.jtheque.core.managers.state; | |
2 | ||
3 | import org.jtheque.core.managers.ManagerException; | |
4 | ||
5 | /* | |
6 | * This file is part of JTheque. | |
7 | * | |
8 | * JTheque is free software: you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation, either version 3 of the License. | |
11 | * | |
12 | * JTheque is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | /** | |
22 | * A state manager. It seems a manager who's responsible for the persistence of the states. | |
23 | * | |
24 | * @author Baptiste Wicht | |
25 | */ | |
26 | public interface IStateManager { | |
27 | /** | |
28 | * Register a new state. | |
29 | * | |
30 | * @param state The state to register. | |
31 | */ | |
32 | void registerState(IState state); | |
33 | ||
34 | /** | |
35 | * Return the state of a certain class. | |
36 | * | |
37 | * @param <T> The state type. | |
38 | * @param c The state class. | |
39 | * @return The state. | |
40 | */ | |
41 | <T extends IState> T getState(Class<T> c); | |
42 | ||
43 | /** | |
44 | * Return the state of a certain class. If the state has not been yet created, it would be created. | |
45 | * | |
46 | * @param <T> The state type. | |
47 | * @param c The state class. | |
48 | * @return The state. | |
49 | * @throws StateException If an error occurs during the state getting. | |
50 | */ | |
51 | <T extends IState> T getOrCreateState(Class<T> c) throws StateException; | |
52 | ||
53 | /** | |
54 | * Create and return a state. | |
55 | * | |
56 | * @param <T> The state type. | |
57 | * @param c The state class. | |
58 | * @return The state. | |
59 | * @throws StateException If an error occurs during the state creation. | |
60 | */ | |
61 | <T extends IState> T createState(Class<T> c) throws StateException; | |
62 | ||
63 | /** | |
64 | * Load the states. | |
65 | * | |
66 | * @throws ManagerException If an error occurs during the state loading. | |
67 | */ | |
68 | void loadStates() throws ManagerException; | |
69 | } |