diff --git a/core/src/net/sf/openrocket/file/motor/RockSimMotorLoader.java b/core/src/net/sf/openrocket/file/motor/RockSimMotorLoader.java index d2bbcd265..5b0743e14 100644 --- a/core/src/net/sf/openrocket/file/motor/RockSimMotorLoader.java +++ b/core/src/net/sf/openrocket/file/motor/RockSimMotorLoader.java @@ -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"); diff --git a/core/src/net/sf/openrocket/motor/Motor.java b/core/src/net/sf/openrocket/motor/Motor.java index fda0eebb9..afe062126 100644 --- a/core/src/net/sf/openrocket/motor/Motor.java +++ b/core/src/net/sf/openrocket/motor/Motor.java @@ -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.