View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.agent.module.datatypes;
2   
3   import cz.cuni.amis.pogamut.usar2004.agent.module.geometry.*;
4   
5   /**
6    * List of all Robot geometry Types. Each type can possibly represent more kinds
7    * of geometry 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 GeometryType
13  {
14      GROUND_VEHICLE(GeoGround.class, "GroundVehicle"),
15      LEGGED_ROBOT(GeoLegged.class, "LeggedRobot"),
16      NAUTIC_VEHICLE(GeoNautic.class, "NauticVehicle"),
17      AERIAL_VEHICLE(GeoAerial.class, "AerialVehicle"),
18      SENSOR_EFFECTER(GeoSensorEffecter.class, "Sensor", "Effecter"),
19      MISSION_PACKAGE(GeoMissionPackage.class, "MisPkg");
20      private String[] kinds;
21      private Class clazz;
22  
23      /**
24       *
25       * @param type - type of the geometry message
26       * @param clazz - class that carries data about this type of geometry
27       */
28      GeometryType(Class clazz, String... kinds)
29      {
30          this.kinds = kinds;
31          this.clazz = clazz;
32      }
33  
34      /**
35       * For each geometry type it checks if <B>type</B> matches one of
36       * <B>kinds</B>. If so, it returns relevant GeometryType. Notice that this
37       * method is static. If nothing matches, it returns SENSOR_EFECTER
38       *
39       * @param type String representation or kind of Geometry
40       * @return Returns relevant GeometryType value to the String <B>type</B>
41       */
42      public static GeometryType getType(String type)
43      {
44          for(GeometryType geoType : GeometryType.values())
45          {
46              for(String kind : geoType.kinds)
47              {
48                  if(kind.equalsIgnoreCase(type))
49                  {
50                      return geoType;
51                  }
52              }
53          }
54          return SENSOR_EFFECTER;
55      }
56  
57      /**
58       * Notice that this method is not static.
59       *
60       * @return Returns class relevant to Actual GeometryType
61       */
62      public Class getModuleClass()
63      {
64          return this.clazz;
65      }
66  }