diff --git a/src/java/org/apache/commons/lang/mutable/MutableBoolean.java b/src/java/org/apache/commons/lang/mutable/MutableBoolean.java index b333823d0..ac7322c08 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableBoolean.java +++ b/src/java/org/apache/commons/lang/mutable/MutableBoolean.java @@ -67,57 +67,7 @@ public class MutableBoolean implements Mutable, Serializable, Comparabl this.value = value.booleanValue(); } - // ----------------------------------------------------------------------- - /** - * Returns the value of this MutableBoolean as a boolean. - * - * @return the boolean value represented by this object. - */ - public boolean booleanValue() { - return value; - } - //----------------------------------------------------------------------- - /** - * Gets this mutable as an instance of Boolean. - * - * @return a Boolean instance containing the value from this mutable, never null - */ - public Boolean toBoolean() { - return Boolean.valueOf(booleanValue()); - } - - //----------------------------------------------------------------------- - /** - * Compares this mutable to another in ascending order. - * - * @param other the other mutable to compare to, not null - * @return negative if this is less, zero if equal, positive if greater - * where false is less than true - */ - public int compareTo(MutableBoolean other) { - boolean anotherVal = other.value; - return value == anotherVal ? 0 : (value ? 1 : -1); - } - - // ----------------------------------------------------------------------- - /** - * Compares this object to the specified object. The result is true if and only if the argument is - * not null and is an MutableBoolean object that contains the same - * boolean value as this object. - * - * @param obj the object to compare with, null returns false - * @return true if the objects are the same; false otherwise. - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof MutableBoolean) { - return value == ((MutableBoolean) obj).booleanValue(); - } - return false; - } - - // ----------------------------------------------------------------------- /** * Gets the value as a Boolean instance. * @@ -127,16 +77,6 @@ public class MutableBoolean implements Mutable, Serializable, Comparabl return Boolean.valueOf(this.value); } - /** - * Returns a suitable hash code for this mutable. - * - * @return the hash code returned by Boolean.TRUE or Boolean.FALSE - */ - @Override - public int hashCode() { - return value ? Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode(); - } - /** * Sets the value. * @@ -156,6 +96,66 @@ public class MutableBoolean implements Mutable, Serializable, Comparabl this.value = value.booleanValue(); } + //----------------------------------------------------------------------- + /** + * Returns the value of this MutableBoolean as a boolean. + * + * @return the boolean value represented by this object. + */ + public boolean booleanValue() { + return value; + } + + //----------------------------------------------------------------------- + /** + * Gets this mutable as an instance of Boolean. + * + * @return a Boolean instance containing the value from this mutable, never null + */ + public Boolean toBoolean() { + return Boolean.valueOf(booleanValue()); + } + + //----------------------------------------------------------------------- + /** + * Compares this object to the specified object. The result is true if and only if the argument is + * not null and is an MutableBoolean object that contains the same + * boolean value as this object. + * + * @param obj the object to compare with, null returns false + * @return true if the objects are the same; false otherwise. + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof MutableBoolean) { + return value == ((MutableBoolean) obj).booleanValue(); + } + return false; + } + + /** + * Returns a suitable hash code for this mutable. + * + * @return the hash code returned by Boolean.TRUE or Boolean.FALSE + */ + @Override + public int hashCode() { + return value ? Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode(); + } + + //----------------------------------------------------------------------- + /** + * Compares this mutable to another in ascending order. + * + * @param other the other mutable to compare to, not null + * @return negative if this is less, zero if equal, positive if greater + * where false is less than true + */ + public int compareTo(MutableBoolean other) { + boolean anotherVal = other.value; + return value == anotherVal ? 0 : (value ? 1 : -1); + } + //----------------------------------------------------------------------- /** * Returns the String value of this mutable. diff --git a/src/java/org/apache/commons/lang/mutable/MutableByte.java b/src/java/org/apache/commons/lang/mutable/MutableByte.java index 2667a35f3..ea422b28d 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableByte.java +++ b/src/java/org/apache/commons/lang/mutable/MutableByte.java @@ -103,6 +103,68 @@ public class MutableByte extends Number implements Comparable, Muta this.value = value.byteValue(); } + //----------------------------------------------------------------------- + /** + * Increments the value. + * + * @since Commons Lang 2.2 + */ + public void increment() { + value++; + } + + /** + * Decrements the value. + * + * @since Commons Lang 2.2 + */ + public void decrement() { + value--; + } + + //----------------------------------------------------------------------- + /** + * Adds a value to the value of this instance. + * + * @param operand the value to add, not null + * @since Commons Lang 2.2 + */ + public void add(byte operand) { + this.value += operand; + } + + /** + * Adds a value to the value of this instance. + * + * @param operand the value to add, not null + * @throws NullPointerException if the object is null + * @since Commons Lang 2.2 + */ + public void add(Number operand) { + this.value += operand.byteValue(); + } + + /** + * Subtracts a value from the value of this instance. + * + * @param operand the value to subtract, not null + * @since Commons Lang 2.2 + */ + public void subtract(byte operand) { + this.value -= operand; + } + + /** + * Subtracts a value from the value of this instance. + * + * @param operand the value to subtract, not null + * @throws NullPointerException if the object is null + * @since Commons Lang 2.2 + */ + public void subtract(Number operand) { + this.value -= operand.byteValue(); + } + //----------------------------------------------------------------------- // shortValue relies on Number implementation /** @@ -165,68 +227,6 @@ public class MutableByte extends Number implements Comparable, Muta return Byte.valueOf(byteValue()); } - //----------------------------------------------------------------------- - /** - * Increments the value. - * - * @since Commons Lang 2.2 - */ - public void increment() { - value++; - } - - /** - * Decrements the value. - * - * @since Commons Lang 2.2 - */ - public void decrement() { - value--; - } - - //----------------------------------------------------------------------- - /** - * Adds a value to the value of this instance. - * - * @param operand the value to add, not null - * @since Commons Lang 2.2 - */ - public void add(byte operand) { - this.value += operand; - } - - /** - * Adds a value to the value of this instance. - * - * @param operand the value to add, not null - * @throws NullPointerException if the object is null - * @since Commons Lang 2.2 - */ - public void add(Number operand) { - this.value += operand.byteValue(); - } - - /** - * Subtracts a value from the value of this instance. - * - * @param operand the value to subtract, not null - * @since Commons Lang 2.2 - */ - public void subtract(byte operand) { - this.value -= operand; - } - - /** - * Subtracts a value from the value of this instance. - * - * @param operand the value to subtract, not null - * @throws NullPointerException if the object is null - * @since Commons Lang 2.2 - */ - public void subtract(Number operand) { - this.value -= operand.byteValue(); - } - //----------------------------------------------------------------------- /** * Compares this object to the specified object. The result is true if and only if the argument is diff --git a/src/java/org/apache/commons/lang/mutable/MutableDouble.java b/src/java/org/apache/commons/lang/mutable/MutableDouble.java index 6bc0864f9..eef25fbcf 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableDouble.java +++ b/src/java/org/apache/commons/lang/mutable/MutableDouble.java @@ -104,47 +104,6 @@ public class MutableDouble extends Number implements Comparable, } //----------------------------------------------------------------------- - // shortValue and bytValue rely on Number implementation - /** - * Returns the value of this MutableDouble as an int. - * - * @return the numeric value represented by this object after conversion to type int. - */ - @Override - public int intValue() { - return (int) value; - } - - /** - * Returns the value of this MutableDouble as a long. - * - * @return the numeric value represented by this object after conversion to type long. - */ - @Override - public long longValue() { - return (long) value; - } - - /** - * Returns the value of this MutableDouble as a float. - * - * @return the numeric value represented by this object after conversion to type float. - */ - @Override - public float floatValue() { - return (float) value; - } - - /** - * Returns the value of this MutableDouble as a double. - * - * @return the numeric value represented by this object after conversion to type double. - */ - @Override - public double doubleValue() { - return value; - } - /** * Checks whether the double value is the special NaN value. * @@ -163,16 +122,6 @@ public class MutableDouble extends Number implements Comparable, return Double.isInfinite(value); } - //----------------------------------------------------------------------- - /** - * Gets this mutable as an instance of Double. - * - * @return a Double instance containing the value from this mutable, never null - */ - public Double toDouble() { - return Double.valueOf(doubleValue()); - } - //----------------------------------------------------------------------- /** * Increments the value. @@ -235,6 +184,58 @@ public class MutableDouble extends Number implements Comparable, this.value -= operand.doubleValue(); } + //----------------------------------------------------------------------- + // shortValue and bytValue rely on Number implementation + /** + * Returns the value of this MutableDouble as an int. + * + * @return the numeric value represented by this object after conversion to type int. + */ + @Override + public int intValue() { + return (int) value; + } + + /** + * Returns the value of this MutableDouble as a long. + * + * @return the numeric value represented by this object after conversion to type long. + */ + @Override + public long longValue() { + return (long) value; + } + + /** + * Returns the value of this MutableDouble as a float. + * + * @return the numeric value represented by this object after conversion to type float. + */ + @Override + public float floatValue() { + return (float) value; + } + + /** + * Returns the value of this MutableDouble as a double. + * + * @return the numeric value represented by this object after conversion to type double. + */ + @Override + public double doubleValue() { + return value; + } + + //----------------------------------------------------------------------- + /** + * Gets this mutable as an instance of Double. + * + * @return a Double instance containing the value from this mutable, never null + */ + public Double toDouble() { + return Double.valueOf(doubleValue()); + } + //----------------------------------------------------------------------- /** * Compares this object against the specified object. The result is true if and only if the argument diff --git a/src/java/org/apache/commons/lang/mutable/MutableFloat.java b/src/java/org/apache/commons/lang/mutable/MutableFloat.java index 253b984e7..57b20e152 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableFloat.java +++ b/src/java/org/apache/commons/lang/mutable/MutableFloat.java @@ -103,6 +103,25 @@ public class MutableFloat extends Number implements Comparable, Mu this.value = value.floatValue(); } + //----------------------------------------------------------------------- + /** + * Checks whether the float value is the special NaN value. + * + * @return true if NaN + */ + public boolean isNaN() { + return Float.isNaN(value); + } + + /** + * Checks whether the float value is infinite. + * + * @return true if infinite + */ + public boolean isInfinite() { + return Float.isInfinite(value); + } + //----------------------------------------------------------------------- /** * Increments the value. @@ -207,24 +226,6 @@ public class MutableFloat extends Number implements Comparable, Mu return value; } - /** - * Checks whether the float value is the special NaN value. - * - * @return true if NaN - */ - public boolean isNaN() { - return Float.isNaN(value); - } - - /** - * Checks whether the float value is infinite. - * - * @return true if infinite - */ - public boolean isInfinite() { - return Float.isInfinite(value); - } - //----------------------------------------------------------------------- /** * Gets this mutable as an instance of Float.