Added convience method UnitGroup.getUnit( String ) which returns the Unit correspondi...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Thu, 26 Apr 2012 18:20:10 +0000 (18:20 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Thu, 26 Apr 2012 18:20:10 +0000 (18:20 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@619 180e2498-e6e9-4542-8430-84ac67f01cd8

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