Created static function Motor.Type.fromName( String ) to Motor.Type based on the logic in RockSimMotorLoader. Use this new lookup method in RockSimMotorLoader. This method was moved because it is useful to have it in Android project motor database.

This commit is contained in:
Kevin Ruland 2012-01-12 19:32:23 +00:00
parent f881014f26
commit 2581bd8fcf
2 changed files with 16 additions and 9 deletions

View 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");

View 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.