You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
588 B
30 lines
588 B
package com.iflytop.gd.system.constants;
|
|
|
|
public enum DistanceUnit {
|
|
MM, CM;
|
|
|
|
public Integer toMM(Integer value) {
|
|
if (this == MM) {
|
|
return value;
|
|
}
|
|
|
|
if (this == CM) {
|
|
return value * 10;
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
|
|
public static DistanceUnit toDistanceUnit(String unitString) {
|
|
if ("mm".equals(unitString)) {
|
|
return MM;
|
|
}
|
|
|
|
if ("cm".equals(unitString)) {
|
|
return CM;
|
|
}
|
|
|
|
throw new IllegalArgumentException("Unknown distance unit " + unitString);
|
|
}
|
|
}
|