]> git.gag.com Git - debian/openrocket/commitdiff
Created static function Motor.Type.fromName( String ) to Motor.Type based on the...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Thu, 12 Jan 2012 19:32:23 +0000 (19:32 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Thu, 12 Jan 2012 19:32:23 +0000 (19:32 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@342 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/file/motor/RockSimMotorLoader.java
core/src/net/sf/openrocket/motor/Motor.java

index d2bbcd265e0e83ec29d436a635716b4029f86fc8..5b0743e144cfcfae13694acd60e7f4d915842b62 100644 (file)
@@ -234,15 +234,7 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
                        
                        // 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");
index fda0eebb971c8753b534ecbb8e6cd32cd23a61ba..afe062126afee169068fddeb3d2443adcc1876f6 100644 (file)
@@ -22,6 +22,21 @@ public interface Motor {
                        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.