Java Reference
In-Depth Information
Since these two classes are used to track the overall state of the application, they are managed by a StateFactory
class that creates both objects and provides them on demand.
Example 3.28 StateFactory.java
1. public class StateFactory {
2. public static final State CLEAN = new CleanState();
3. public static final State DIRTY = new DirtyState();
4. private static State currentState = CLEAN;
5.
6. public static State getCurrentState(){
7. return currentState;
8. }
9.
10. public static void setCurrentState(State state){
11. currentState = state;
12. }
13. }
14.
Search WWH ::




Custom Search