1 package cz.cuni.amis.pogamut.base.component.controller;
2
3 import java.util.HashSet;
4 import java.util.Set;
5
6 public enum ComponentState {
7
8 INSTANTIATED, STARTING, STARTING_PAUSED, RUNNING, PAUSING, PAUSED, RESUMING, STOPPING, STOPPED, KILLING, KILLED, RESETTING, RESETED;
9
10
11
12
13
14
15
16 public static boolean inside(ComponentState state, ComponentState... inside) {
17 for (ComponentState cs : inside) {
18 if (state.equals(cs)) return true;
19 }
20 return false;
21 }
22
23
24
25
26
27
28
29 public static boolean partOf(ComponentState[] states, ComponentState ... inside) {
30 Set<ComponentState> insideSet = new HashSet<ComponentState>();
31 for (ComponentState state : inside) {
32 insideSet.add(state);
33 }
34 for (ComponentState state : states) {
35 if (insideSet.contains(state)) return true;
36 }
37 return false;
38 }
39
40
41
42
43
44
45
46 public static boolean notInside(ComponentState state, ComponentState... inside) {
47 for (ComponentState cs : inside) {
48 if (state.equals(cs)) return false;
49 }
50 return true;
51 }
52
53 }