Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / core / src / net / sf / openrocket / unit / FixedUnitGroup.java
diff --git a/core/src/net/sf/openrocket/unit/FixedUnitGroup.java b/core/src/net/sf/openrocket/unit/FixedUnitGroup.java
new file mode 100644 (file)
index 0000000..8cb6fde
--- /dev/null
@@ -0,0 +1,35 @@
+package net.sf.openrocket.unit;
+
+/*
+ * This class provides a 'dumb' version of UnitGroup
+ * It allows any arbitrary unit to be created. It doesn't store any value and can't be converted into anything else.
+ * This is useful for custom expression units.
+ * 
+ * @author Richard Graham
+ */
+
+public class FixedUnitGroup extends UnitGroup {
+       
+       String unitString;
+       
+       public FixedUnitGroup( String unitString ){
+               this.unitString = unitString; 
+       }
+       
+       public int getUnitCount(){
+               return 1;
+       }
+       
+       public Unit getDefaultUnit(){
+               return new GeneralUnit(1, unitString);
+       }
+       
+       public Unit getSIUnit(){
+               return new GeneralUnit(1, unitString);
+       }
+       
+       public boolean contains(Unit u){
+               return true;
+       }
+       
+}