Reorder methods for consistency within package
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@830028 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ffeea79694
commit
6bc82fa5f6
|
@ -67,57 +67,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl
|
||||||
this.value = value.booleanValue();
|
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 <code>true</code> if and only if the argument is
|
|
||||||
* not <code>null</code> and is an <code>MutableBoolean</code> object that contains the same
|
|
||||||
* <code>boolean</code> value as this object.
|
|
||||||
*
|
|
||||||
* @param obj the object to compare with, null returns false
|
|
||||||
* @return <code>true</code> if the objects are the same; <code>false</code> 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.
|
* Gets the value as a Boolean instance.
|
||||||
*
|
*
|
||||||
|
@ -127,16 +77,6 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl
|
||||||
return Boolean.valueOf(this.value);
|
return Boolean.valueOf(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a suitable hash code for this mutable.
|
|
||||||
*
|
|
||||||
* @return the hash code returned by <code>Boolean.TRUE</code> or <code>Boolean.FALSE</code>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return value ? Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value.
|
* Sets the value.
|
||||||
*
|
*
|
||||||
|
@ -156,6 +96,66 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl
|
||||||
this.value = value.booleanValue();
|
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 <code>true</code> if and only if the argument is
|
||||||
|
* not <code>null</code> and is an <code>MutableBoolean</code> object that contains the same
|
||||||
|
* <code>boolean</code> value as this object.
|
||||||
|
*
|
||||||
|
* @param obj the object to compare with, null returns false
|
||||||
|
* @return <code>true</code> if the objects are the same; <code>false</code> 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 <code>Boolean.TRUE</code> or <code>Boolean.FALSE</code>
|
||||||
|
*/
|
||||||
|
@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.
|
* Returns the String value of this mutable.
|
||||||
|
|
|
@ -103,6 +103,68 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta
|
||||||
this.value = value.byteValue();
|
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
|
// shortValue relies on Number implementation
|
||||||
/**
|
/**
|
||||||
|
@ -165,68 +227,6 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta
|
||||||
return Byte.valueOf(byteValue());
|
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 <code>true</code> if and only if the argument is
|
* Compares this object to the specified object. The result is <code>true</code> if and only if the argument is
|
||||||
|
|
|
@ -104,47 +104,6 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// 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.
|
* Checks whether the double value is the special NaN value.
|
||||||
*
|
*
|
||||||
|
@ -163,16 +122,6 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
|
||||||
return Double.isInfinite(value);
|
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.
|
* Increments the value.
|
||||||
|
@ -235,6 +184,58 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
|
||||||
this.value -= operand.doubleValue();
|
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 <code>true</code> if and only if the argument
|
* Compares this object against the specified object. The result is <code>true</code> if and only if the argument
|
||||||
|
|
|
@ -103,6 +103,25 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu
|
||||||
this.value = value.floatValue();
|
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.
|
* Increments the value.
|
||||||
|
@ -207,24 +226,6 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu
|
||||||
return value;
|
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.
|
* Gets this mutable as an instance of Float.
|
||||||
|
|
Loading…
Reference in New Issue