Add toType methods to return the primitive wrapper object
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@240419 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7ea69942ef
commit
e763c5a388
|
@ -143,6 +143,16 @@ 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 against the specified object. The result is <code>true</code> if and only if the argument
|
||||
|
|
|
@ -154,6 +154,16 @@ public boolean isInfinite() {
|
|||
return Double.isInfinite(value);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets this mutable as an instance of Double.
|
||||
*
|
||||
* @return a Double instance containing the value from this mutable
|
||||
*/
|
||||
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
|
||||
|
|
|
@ -154,6 +154,17 @@ public boolean isInfinite() {
|
|||
return Float.isInfinite(value);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets this mutable as an instance of Float.
|
||||
*
|
||||
* @return a Float instance containing the value from this mutable
|
||||
*/
|
||||
public Float toFloat() {
|
||||
return new Float(floatValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Compares this object against some other object. The result is <code>true</code> if and only if the argument is
|
||||
* not <code>null</code> and is a <code>Float</code> object that represents a <code>float</code> that has the
|
||||
|
|
|
@ -134,6 +134,16 @@ public double doubleValue() {
|
|||
return value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets this mutable as an instance of Integer.
|
||||
*
|
||||
* @return a Integer instance containing the value from this mutable
|
||||
*/
|
||||
public Integer toInteger() {
|
||||
return new Integer(intValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Compares this object to the specified object. The result is <code>true</code> if and only if the argument is
|
||||
|
|
|
@ -134,6 +134,16 @@ public double doubleValue() {
|
|||
return value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets this mutable as an instance of Long.
|
||||
*
|
||||
* @return a Long instance containing the value from this mutable
|
||||
*/
|
||||
public Long toLong() {
|
||||
return new Long(longValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Compares this object against the specified object. The result is <code>true</code> if and only if the argument
|
||||
|
|
|
@ -143,6 +143,16 @@ public double doubleValue() {
|
|||
return value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets this mutable as an instance of Short.
|
||||
*
|
||||
* @return a Short instance containing the value from this mutable
|
||||
*/
|
||||
public Short toShort() {
|
||||
return new Short(shortValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Compares this object against the specified object. The result is <code>true</code> if and only if the argument
|
||||
|
|
|
@ -139,6 +139,11 @@ public void testPrimitiveValues() {
|
|||
assertEquals( 1L, mutNum.longValue() );
|
||||
}
|
||||
|
||||
public void testToByte() {
|
||||
assertEquals(new Byte((byte) 0), new MutableByte((byte) 0).toByte());
|
||||
assertEquals(new Byte((byte) 123), new MutableByte((byte) 123).toByte());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0", new MutableByte((byte) 0).toString());
|
||||
assertEquals("10", new MutableByte((byte) 10).toString());
|
||||
|
|
|
@ -150,6 +150,11 @@ public void testPrimitiveValues() {
|
|||
assertEquals( 1L, mutNum.longValue() );
|
||||
}
|
||||
|
||||
public void testToDouble() {
|
||||
assertEquals(new Double(0d), new MutableDouble(0d).toDouble());
|
||||
assertEquals(new Double(12.3d), new MutableDouble(12.3d).toDouble());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0.0", new MutableDouble(0d).toString());
|
||||
assertEquals("10.0", new MutableDouble(10d).toString());
|
||||
|
|
|
@ -150,6 +150,11 @@ public void testPrimitiveValues() {
|
|||
assertEquals( 1L, mutNum.longValue() );
|
||||
}
|
||||
|
||||
public void testToFloat() {
|
||||
assertEquals(new Float(0f), new MutableFloat(0f).toFloat());
|
||||
assertEquals(new Float(12.3f), new MutableFloat(12.3f).toFloat());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0.0", new MutableFloat(0f).toString());
|
||||
assertEquals("10.0", new MutableFloat(10f).toString());
|
||||
|
|
|
@ -145,6 +145,11 @@ public void testPrimitiveValues() {
|
|||
assertEquals( 1L, mutNum.longValue() );
|
||||
}
|
||||
|
||||
public void testToInteger() {
|
||||
assertEquals(new Integer(0), new MutableInt(0).toInteger());
|
||||
assertEquals(new Integer(123), new MutableInt(123).toInteger());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0", new MutableInt(0).toString());
|
||||
assertEquals("10", new MutableInt(10).toString());
|
||||
|
|
|
@ -139,6 +139,11 @@ public void testPrimitiveValues() {
|
|||
assertEquals( 1L, mutNum.longValue() );
|
||||
}
|
||||
|
||||
public void testToLong() {
|
||||
assertEquals(new Long(0L), new MutableLong(0L).toLong());
|
||||
assertEquals(new Long(123L), new MutableLong(123L).toLong());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0", new MutableLong(0).toString());
|
||||
assertEquals("10", new MutableLong(10).toString());
|
||||
|
|
|
@ -139,6 +139,11 @@ public void testPrimitiveValues() {
|
|||
assertEquals( 1L, mutNum.longValue() );
|
||||
}
|
||||
|
||||
public void testToShort() {
|
||||
assertEquals(new Short((short) 0), new MutableShort((short) 0).toShort());
|
||||
assertEquals(new Short((short) 123), new MutableShort((short) 123).toShort());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0", new MutableShort((short) 0).toString());
|
||||
assertEquals("10", new MutableShort((short) 10).toString());
|
||||
|
|
Loading…
Reference in New Issue