View Javadoc

1   package cz.cuni.amis.pogamut.defcon.consts.state;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import javabot.JBot;
7   
8   /**
9    * Contains all states for Nukes.
10   * 
11   * @author Radek 'Black_Hand' Pibil
12   *
13   */
14  public enum NukeState implements IState {
15  
16  	ON_TARGET(JBot.STATE_NUKEONTARGET),
17  	DISARM(JBot.STATE_NUKEDISARM);
18  	
19  	private static Map<Integer, NukeState> states = new HashMap<Integer, NukeState>();
20  	
21  	public static NukeState getState(int stateId) {
22  		return states.get(stateId);
23  	}
24  	
25  	static {
26  		for (NukeState state : NukeState.values()) {
27  			states.put(state.getStateId(), state);
28  		}
29  	}
30  
31  	
32  	public final int id;
33  	
34  	private NukeState(int id) {
35  		this.id = id;
36  	}
37  
38  	@Override
39  	public int getStateId() {
40  		return id;
41  	}
42      
43  	@Override
44  	public Enum<? extends IState> getEnum() {
45  		return this;
46  	}
47  }