X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fnet%2Fsf%2Fopenrocket%2Funit%2FValue.java;h=65382523cf98e783e80d29b1e54d6d9b222eea3d;hb=8320c04afa30e2aa0150adc870d02abeedb01066;hp=278b815a9264a63f7fafb179dc11714c68d7d91b;hpb=6460090e9ec07b12234369583032d02d7c5ed3b1;p=debian%2Fopenrocket diff --git a/src/net/sf/openrocket/unit/Value.java b/src/net/sf/openrocket/unit/Value.java index 278b815a..65382523 100644 --- a/src/net/sf/openrocket/unit/Value.java +++ b/src/net/sf/openrocket/unit/Value.java @@ -3,7 +3,7 @@ package net.sf.openrocket.unit; import net.sf.openrocket.util.MathUtil; /** - * A class representing an SI value and a unit. The toString() method yields the + * An immutable class representing an SI value and a unit. The toString() method yields the * current value in the current units. This class may be used to encapsulate * a sortable value for example for tables. The sorting is performed by the * value in the current units, ignoring the unit. @@ -12,8 +12,8 @@ import net.sf.openrocket.util.MathUtil; */ public class Value implements Comparable { - private double value; - private Unit unit; + private final double value; + private final Unit unit; /** @@ -44,7 +44,7 @@ public class Value implements Comparable { /** - * Get the value of this object. + * Get the value of this object (in SI units). * * @return the value */ @@ -52,16 +52,8 @@ public class Value implements Comparable { return value; } - /** - * Set the value of this object. - * - * @param value the value to set - */ - public void setValue(double value) { - this.value = value; - } - + /** * Get the value of this object in the current units. * @@ -72,16 +64,6 @@ public class Value implements Comparable { } - /** - * Set the value of this object in the current units. - * - * @param value the value in current units. - */ - public void setUnitValue(double value) { - this.value = unit.fromUnit(value); - } - - /** * Get the unit of this object. * @@ -91,18 +73,6 @@ public class Value implements Comparable { return unit; } - /** - * Set the value of this object. - * - * @param unit the unit to set (null not allowed) - */ - public void setUnit(Unit unit) { - if (unit == null) { - throw new IllegalArgumentException("unit is null"); - } - this.unit = unit; - } - /** * Return a string formatted using the {@link Unit#toStringUnit(double)} method