View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.agent.module.datatypes;
2   
3   import cz.cuni.amis.pogamut.usar2004.agent.module.configuration.*;
4   
5   /**
6    * List of all Robot config Types. Each type can possibly represent more kinds
7    * of config of same type. For each enum record, there exists relevant Class
8    * which can be returned on demand.
9    *
10   * @author vejmanm
11   */
12  public enum ConfigType
13  {
14      GROUND_VEHICLE(ConfigGround.class, "GroundVehicle"),
15      LEGGED_ROBOT(ConfigLegged.class, "LeggedRobot"),
16      NAUTIC_VEHICLE(ConfigNautic.class, "NauticVehicle"),
17      AERIAL_VEHICLE(ConfigAerial.class, "AerialVehicle"),
18      SENSOR(ConfigSensor.class, "Sensor"),
19      EFFECTER(ConfigEffecter.class, "Effecter"),
20      MISSION_PACKAGE(ConfigMissionPackage.class, "MisPkg");
21      private String kind;
22      private Class clazz;
23  
24      /**
25       *
26       * @param type - type of the config message
27       * @param clazz - class that carries data about this type of config
28       */
29      ConfigType(Class clazz, String kind)
30      {
31          this.kind = kind;
32          this.clazz = clazz;
33      }
34  
35      /**
36       * For each config type it checks if <B>type</B> matches one of
37       * <B>kinds</B>. If so, it returns relevant ConfigType. Notice that this
38       * method is static. If nothing matches, it returns SENSOR
39       *
40       * @param type String representation or kind of Config
41       * @return Returns relevant ConfigType value to the String <B>type</B>
42       */
43      public static ConfigType getType(String type)
44      {
45          for(ConfigType geoType : ConfigType.values())
46          {
47              if(geoType.kind.equalsIgnoreCase(type))
48              {
49                  return geoType;
50              }
51          }
52          return SENSOR;
53      }
54  
55      /**
56       * Notice that this method is not static.
57       *
58       * @return Returns class relevant to Actual ConfigType
59       */
60      public Class getModuleClass()
61      {
62          return this.clazz;
63      }
64  }