git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@342
180e2498-e6e9-4542-8430-
84ac67f01cd8
// Motor type
str = attributes.get("Type");
- if (str != null && str.equalsIgnoreCase("single-use")) {
- type = Motor.Type.SINGLE;
- } else if (str != null && str.equalsIgnoreCase("hybrid")) {
- type = Motor.Type.HYBRID;
- } else if (str != null && str.equalsIgnoreCase("reloadable")) {
- type = Motor.Type.RELOAD;
- } else {
- type = Motor.Type.UNKNOWN;
- }
+ type = Motor.Type.fromName(str);
// Calculate mass
str = attributes.get("auto-calc-mass");
this.name = name;
this.description = description;
}
+
+ public static Type fromName( String name ) {
+ if ( name == null ) {
+ return UNKNOWN;
+ }
+ if ("single-use".equalsIgnoreCase(name)) {
+ return SINGLE;
+ } else if ("hybrid".equalsIgnoreCase(name)) {
+ return HYBRID;
+ } else if ("reloadable".equalsIgnoreCase(name)) {
+ return RELOAD;
+ } else {
+ return UNKNOWN;
+ }
+ }
/**
* Return a short name of this motor type.