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:
parent
f881014f26
commit
2581bd8fcf
@ -234,15 +234,7 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
|
|
||||||
// Motor type
|
// Motor type
|
||||||
str = attributes.get("Type");
|
str = attributes.get("Type");
|
||||||
if (str != null && str.equalsIgnoreCase("single-use")) {
|
type = Motor.Type.fromName(str);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate mass
|
// Calculate mass
|
||||||
str = attributes.get("auto-calc-mass");
|
str = attributes.get("auto-calc-mass");
|
||||||
|
@ -22,6 +22,21 @@ public interface Motor {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
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.
|
* Return a short name of this motor type.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user