View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.agent.module.datatypes;
2   
3   import cz.cuni.amis.pogamut.usar2004.agent.module.state.*;
4   
5   /**
6    * Descriptor of vehicle type. Every robot should by one of following types:
7    * Ground, Nautic, Aerial or Legged Robot.
8    *
9    * @author vejmanm
10   */
11  public enum VehicleType
12  {
13      GROUND_VEHICLE(StateGround.class),
14      LEGGED_ROBOT(StateLegged.class),
15      NAUTIC_VEHICLE(StateNautic.class),
16      AERIAL_VEHICLE(StateAerial.class),
17      UNKNOWN(SuperState.class);
18      private Class clazz;
19  
20      VehicleType(Class clazz)
21      {
22          this.clazz = clazz;
23      }
24  
25      public Class getModuleClass()
26      {
27          return this.clazz;
28      }
29  
30      /**
31       * Used for creating instances of state message representatives.
32       *
33       * @param type String representation of vehicle type.
34       * @return Returns corresponding enum element.
35       */
36      public static VehicleType getType(String type)
37      {
38          if(type.equalsIgnoreCase("GroundVehicle") || type.equalsIgnoreCase("Ground"))
39          {
40              return GROUND_VEHICLE;
41          }
42          if(type.equalsIgnoreCase("LeggedRobot") || type.equalsIgnoreCase("Legged"))
43          {
44              return LEGGED_ROBOT;
45          }
46          if(type.equalsIgnoreCase("NauticVehicle") || type.equalsIgnoreCase("Nautic"))
47          {
48              return NAUTIC_VEHICLE;
49          }
50          if(type.equalsIgnoreCase("AerialVehicle") || type.equalsIgnoreCase("Aerial"))
51          {
52              return AERIAL_VEHICLE;
53          }
54          return UNKNOWN;
55      }
56  }