Added convience method UnitGroup.getUnit( String ) which returns the Unit correspondi...
[debian/openrocket] / core / src / net / sf / openrocket / unit / UnitGroup.java
index f72f22a970bc6435757882ad6b74778b45ad6ffa..5a0b692c94febb3b820469e93be661dfc80d2e87 100644 (file)
@@ -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);