Added convience method UnitGroup.getUnit( String ) which returns the Unit corresponding to the abbreviation. Throws IllegalArgumentException if the requested unit does not exist.
This commit is contained in:
parent
b990a5acb2
commit
f2e7cb58ab
@ -419,6 +419,14 @@ public class UnitGroup {
|
||||
throw new IllegalArgumentException("name=" + name);
|
||||
}
|
||||
|
||||
public Unit getUnit( String name ) throws IllegalArgumentException {
|
||||
for (int i = 0; i < units.size(); i++) {
|
||||
if (units.get(i).getUnit().equals(name)) {
|
||||
return units.get(i);
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("name=" + name);
|
||||
}
|
||||
|
||||
public Unit getUnit(int n) {
|
||||
return units.get(n);
|
||||
|
Loading…
x
Reference in New Issue
Block a user