View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.agent.module.datatypes;
2   
3   import cz.cuni.amis.pogamut.usar2004.agent.module.response.*;
4   
5   /**
6    * List of all Robot Response Types. Each type can represent only one kind of
7    * Response type. For each enum record, there exists relevant Class which can be
8    * returned on demand.
9    *
10   * @author vejmanm
11   */
12  public enum ResponseType
13  {
14      CAMERA(ResponseCamera.class, "Camera"),
15      VIEWPORT(Viewport.class, "Viewports"),
16      SENSOR_EFFECTER(ResponseSensorEffecter.class, "");
17      private String kind;
18      private Class clazz;
19  
20      /**
21       *
22       * @param type - type of the Response message
23       * @param clazz - class that carries data about this type of the response
24       */
25      ResponseType(Class clazz, String kind)
26      {
27          this.kind = kind;
28          this.clazz = clazz;
29      }
30  
31      /**
32       * For each Response type it checks if <B>type</B> matches one of
33       * <B>kinds</B>. If so, it returns relevant ResponseType. Notice that this
34       * method is static. If nothing matches, it returns SENSOR_EFFECTER
35       *
36       * @param type String representation or kind of Response
37       * @return Returns relevant ResponseType value to the String <B>type</B>
38       */
39      public static ResponseType getType(String type)
40      {
41          for(ResponseType resType : ResponseType.values())
42          {
43              if(resType.kind.equalsIgnoreCase(type))
44              {
45                  return resType;
46              }
47          }
48          return SENSOR_EFFECTER;
49      }
50  
51      /**
52       * Notice that this method is not static.
53       *
54       * @return Returns class relevant to Actual ResponseType
55       */
56      public Class getModuleClass()
57      {
58          return this.clazz;
59      }
60  }