Use valueOf() to convert primitive to wrapper class
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@830016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bbab0a4b4c
commit
283fa00f77
|
@ -80,6 +80,17 @@ public boolean booleanValue() {
|
||||||
return value;
|
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.
|
* Compares this mutable to another in ascending order.
|
||||||
*
|
*
|
||||||
|
|
|
@ -175,10 +175,10 @@ public boolean isInfinite() {
|
||||||
/**
|
/**
|
||||||
* Gets this mutable as an instance of Double.
|
* Gets this mutable as an instance of Double.
|
||||||
*
|
*
|
||||||
* @return a Double instance containing the value from this mutable
|
* @return a Double instance containing the value from this mutable, never null
|
||||||
*/
|
*/
|
||||||
public Double toDouble() {
|
public Double toDouble() {
|
||||||
return new Double(doubleValue());
|
return Double.valueOf(doubleValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -247,10 +247,10 @@ public boolean isInfinite() {
|
||||||
/**
|
/**
|
||||||
* Gets this mutable as an instance of Float.
|
* Gets this mutable as an instance of Float.
|
||||||
*
|
*
|
||||||
* @return a Float instance containing the value from this mutable
|
* @return a Float instance containing the value from this mutable, never null
|
||||||
*/
|
*/
|
||||||
public Float toFloat() {
|
public Float toFloat() {
|
||||||
return new Float(floatValue());
|
return Float.valueOf(floatValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -231,10 +231,10 @@ public double doubleValue() {
|
||||||
/**
|
/**
|
||||||
* Gets this mutable as an instance of Integer.
|
* Gets this mutable as an instance of Integer.
|
||||||
*
|
*
|
||||||
* @return a Integer instance containing the value from this mutable
|
* @return a Integer instance containing the value from this mutable, never null
|
||||||
*/
|
*/
|
||||||
public Integer toInteger() {
|
public Integer toInteger() {
|
||||||
return new Integer(intValue());
|
return Integer.valueOf(intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -229,10 +229,10 @@ public double doubleValue() {
|
||||||
/**
|
/**
|
||||||
* Gets this mutable as an instance of Long.
|
* Gets this mutable as an instance of Long.
|
||||||
*
|
*
|
||||||
* @return a Long instance containing the value from this mutable
|
* @return a Long instance containing the value from this mutable, never null
|
||||||
*/
|
*/
|
||||||
public Long toLong() {
|
public Long toLong() {
|
||||||
return new Long(longValue());
|
return Long.valueOf(longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -239,10 +239,10 @@ public double doubleValue() {
|
||||||
/**
|
/**
|
||||||
* Gets this mutable as an instance of Short.
|
* Gets this mutable as an instance of Short.
|
||||||
*
|
*
|
||||||
* @return a Short instance containing the value from this mutable
|
* @return a Short instance containing the value from this mutable, never null
|
||||||
*/
|
*/
|
||||||
public Short toShort() {
|
public Short toShort() {
|
||||||
return new Short(shortValue());
|
return Short.valueOf(shortValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -95,11 +95,15 @@ public void testEquals() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetSet() {
|
public void testGetSet() {
|
||||||
final MutableBoolean mutBool = new MutableBoolean(false);
|
|
||||||
assertEquals(false, new MutableBoolean().booleanValue());
|
assertEquals(false, new MutableBoolean().booleanValue());
|
||||||
assertEquals(Boolean.FALSE, new MutableBoolean().getValue());
|
assertEquals(Boolean.FALSE, new MutableBoolean().getValue());
|
||||||
|
|
||||||
|
final MutableBoolean mutBool = new MutableBoolean(false);
|
||||||
|
assertEquals(Boolean.FALSE, mutBool.toBoolean());
|
||||||
|
assertEquals(false, mutBool.booleanValue());
|
||||||
|
|
||||||
mutBool.setValue(Boolean.TRUE);
|
mutBool.setValue(Boolean.TRUE);
|
||||||
|
assertEquals(Boolean.TRUE, mutBool.toBoolean());
|
||||||
assertEquals(true, mutBool.booleanValue());
|
assertEquals(true, mutBool.booleanValue());
|
||||||
|
|
||||||
mutBool.setValue(false);
|
mutBool.setValue(false);
|
||||||
|
|
Loading…
Reference in New Issue