Author: niallp
Date: Mon Feb 1 00:02:15 2010
New Revision: 905144
URL: http://svn.apache.org/viewvc?rev=905144&view=rev
Log:
Port r830028 to 2.x branch - Reorder methods for consistency within package
Modified:
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableBoolean.java
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableByte.java
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableDouble.java
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableFloat.java
Modified:
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableBoolean.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableBoolean.java?rev=905144&r1=905143&r2=905144&view=diff
==============================================================================
---
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableBoolean.java
(original)
+++
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableBoolean.java
Mon Feb 1 00:02:15 2010
@@ -71,26 +71,41 @@
//-----------------------------------------------------------------------
/**
- * Returns the value of this MutableBoolean as a boolean.
+ * Gets the value as a Boolean instance.
*
- * @return the boolean value represented by this object.
+ * @return the value as a Boolean, never null
*/
- public boolean booleanValue() {
- return value;
+ public Object getValue() {
+ return BooleanUtils.toBooleanObject(this.value);
}
/**
- * Compares this mutable to another in ascending order.
+ * Sets the value.
*
- * @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
- * @throws ClassCastException if the argument is not a MutableBoolean
+ * @param value the value to set
*/
- public int compareTo(Object obj) {
- MutableBoolean other = (MutableBoolean) obj;
- boolean anotherVal = other.value;
- return value == anotherVal ? 0 : (value ? 1 : -1);
+ public void setValue(boolean value) {
+ this.value = value;
+ }
+
+ /**
+ * Sets the value from any Boolean instance.
+ *
+ * @param value the value to set, not null
+ * @throws NullPointerException if the object is null
+ */
+ public void setValue(Object value) {
+ setValue(((Boolean) value).booleanValue());
+ }
+
+ //-----------------------------------------------------------------------
+ /**
+ * Returns the value of this MutableBoolean as a boolean.
+ *
+ * @return the boolean value represented by this object.
+ */
+ public boolean booleanValue() {
+ return value;
}
//-----------------------------------------------------------------------
@@ -109,16 +124,6 @@
return false;
}
- //-----------------------------------------------------------------------
- /**
- * Gets the value as a Boolean instance.
- *
- * @return the value as a Boolean, never null
- */
- public Object getValue() {
- return BooleanUtils.toBooleanObject(this.value);
- }
-
/**
* Returns a suitable hash code for this mutable.
*
@@ -128,26 +133,21 @@
return value ? Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode();
}
+ //-----------------------------------------------------------------------
/**
- * Sets the value.
- *
- * @param value the value to set
- */
- public void setValue(boolean value) {
- this.value = value;
- }
-
- /**
- * Sets the value from any Boolean instance.
+ * Compares this mutable to another in ascending order.
*
- * @param value the value to set, not null
- * @throws NullPointerException if the object is null
- * @throws ClassCastException if the type is not a {...@link Boolean}
+ * @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 void setValue(Object value) {
- setValue(((Boolean) value).booleanValue());
+ public int compareTo(Object obj) {
+ MutableBoolean other = (MutableBoolean) obj;
+ boolean anotherVal = other.value;
+ return value == anotherVal ? 0 : (value ? 1 : -1);
}
+ //-----------------------------------------------------------------------
/**
* Returns the String value of this mutable.
*
Modified:
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableByte.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableByte.java?rev=905144&r1=905143&r2=905144&view=diff
==============================================================================
---
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableByte.java
(original)
+++
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableByte.java
Mon Feb 1 00:02:15 2010
@@ -94,63 +94,6 @@
}
//-----------------------------------------------------------------------
- // shortValue relies on Number implementation
- /**
- * Returns the value of this MutableByte as a byte.
- *
- * @return the numeric value represented by this object after conversion
to type byte.
- */
- public byte byteValue() {
- return value;
- }
-
- /**
- * Returns the value of this MutableByte as an int.
- *
- * @return the numeric value represented by this object after conversion
to type int.
- */
- public int intValue() {
- return value;
- }
-
- /**
- * Returns the value of this MutableByte as a long.
- *
- * @return the numeric value represented by this object after conversion
to type long.
- */
- public long longValue() {
- return value;
- }
-
- /**
- * Returns the value of this MutableByte as a float.
- *
- * @return the numeric value represented by this object after conversion
to type float.
- */
- public float floatValue() {
- return value;
- }
-
- /**
- * Returns the value of this MutableByte as a double.
- *
- * @return the numeric value represented by this object after conversion
to type double.
- */
- public double doubleValue() {
- return value;
- }
-
- //-----------------------------------------------------------------------
- /**
- * Gets this mutable as an instance of Byte.
- *
- * @return a Byte instance containing the value from this mutable
- */
- public Byte toByte() {
- return new Byte(byteValue());
- }
-
- //-----------------------------------------------------------------------
/**
* Increments the value.
*
@@ -213,6 +156,63 @@
}
//-----------------------------------------------------------------------
+ // shortValue relies on Number implementation
+ /**
+ * Returns the value of this MutableByte as a byte.
+ *
+ * @return the numeric value represented by this object after conversion
to type byte.
+ */
+ public byte byteValue() {
+ return value;
+ }
+
+ /**
+ * Returns the value of this MutableByte as an int.
+ *
+ * @return the numeric value represented by this object after conversion
to type int.
+ */
+ public int intValue() {
+ return value;
+ }
+
+ /**
+ * Returns the value of this MutableByte as a long.
+ *
+ * @return the numeric value represented by this object after conversion
to type long.
+ */
+ public long longValue() {
+ return value;
+ }
+
+ /**
+ * Returns the value of this MutableByte as a float.
+ *
+ * @return the numeric value represented by this object after conversion
to type float.
+ */
+ public float floatValue() {
+ return value;
+ }
+
+ /**
+ * Returns the value of this MutableByte as a double.
+ *
+ * @return the numeric value represented by this object after conversion
to type double.
+ */
+ public double doubleValue() {
+ return value;
+ }
+
+ //-----------------------------------------------------------------------
+ /**
+ * Gets this mutable as an instance of Byte.
+ *
+ * @return a Byte instance containing the value from this mutable
+ */
+ public Byte toByte() {
+ return new Byte(byteValue());
+ }
+
+ //-----------------------------------------------------------------------
/**
* Compares this object to the specified object. The result is
<code>true</code> if and only if the argument is
* not <code>null</code> and is a <code>MutableByte</code> object that
contains the same <code>byte</code> value
@@ -237,6 +237,7 @@
return value;
}
+ //-----------------------------------------------------------------------
/**
* Compares this mutable to another in ascending order.
*
@@ -250,6 +251,7 @@
return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1);
}
+ //-----------------------------------------------------------------------
/**
* Returns the String value of this mutable.
*
Modified:
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableDouble.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableDouble.java?rev=905144&r1=905143&r2=905144&view=diff
==============================================================================
---
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableDouble.java
(original)
+++
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableDouble.java
Mon Feb 1 00:02:15 2010
@@ -96,43 +96,6 @@
}
//-----------------------------------------------------------------------
- // 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.
- */
- 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.
- */
- 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.
- */
- 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.
- */
- public double doubleValue() {
- return value;
- }
-
/**
* Checks whether the double value is the special NaN value.
*
@@ -153,16 +116,6 @@
//-----------------------------------------------------------------------
/**
- * Gets this mutable as an instance of Double.
- *
- * @return a Double instance containing the value from this mutable, never
null
- */
- public Double toDouble() {
- return new Double(doubleValue());
- }
-
- //-----------------------------------------------------------------------
- /**
* Increments the value.
*
* @since Commons Lang 2.2
@@ -224,6 +177,54 @@
}
//-----------------------------------------------------------------------
+ // 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.
+ */
+ 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.
+ */
+ 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.
+ */
+ 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.
+ */
+ 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 new Double(doubleValue());
+ }
+
+ //-----------------------------------------------------------------------
/**
* Compares this object against the specified object. The result is
<code>true</code> if and only if the argument
* is not <code>null</code> and is a <code>Double</code> object that
represents a double that has the identical
@@ -268,6 +269,7 @@
return (int) (bits ^ (bits >>> 32));
}
+ //-----------------------------------------------------------------------
/**
* Compares this mutable to another in ascending order.
*
@@ -281,6 +283,7 @@
return NumberUtils.compare(value, anotherVal);
}
+ //-----------------------------------------------------------------------
/**
* Returns the String value of this mutable.
*
Modified:
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableFloat.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableFloat.java?rev=905144&r1=905143&r2=905144&view=diff
==============================================================================
---
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableFloat.java
(original)
+++
commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/mutable/MutableFloat.java
Mon Feb 1 00:02:15 2010
@@ -97,6 +97,25 @@
//-----------------------------------------------------------------------
/**
+ * 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.
*
* @since Commons Lang 2.2
@@ -195,24 +214,6 @@
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.