Use more efficient Integer cache: Use "Integer.valueOf(int)" instead of "new Integer(int)".
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1153484 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9d6f32538c
commit
ddeba76d0b
|
@ -288,9 +288,9 @@ public class ArrayUtils {
|
|||
* <p>Note, this method makes only sense to provide arguments of the same type so that the
|
||||
* compiler can deduce the type of the array itself. While it is possible to select the
|
||||
* type explicitly like in
|
||||
* <code>Number[] array = ArrayUtils.<Number>toArray(new Integer(42), new Double(Math.PI))</code>,
|
||||
* <code>Number[] array = ArrayUtils.<Number>toArray(Integer.valueOf(42), new Double(Math.PI))</code>,
|
||||
* there is no real advantage when compared to
|
||||
* <code>new Number[] {new Integer(42), new Double(Math.PI)}</code>.</p>
|
||||
* <code>new Number[] {Integer.valueOf(42), new Double(Math.PI)}</code>.</p>
|
||||
*
|
||||
* @param <T> the array's element type
|
||||
* @param items the varargs array items, null allowed
|
||||
|
|
|
@ -226,9 +226,9 @@ public class BooleanUtils {
|
|||
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
|
||||
*
|
||||
* <pre>
|
||||
* BooleanUtils.toBoolean(new Integer(0)) = Boolean.FALSE
|
||||
* BooleanUtils.toBoolean(new Integer(1)) = Boolean.TRUE
|
||||
* BooleanUtils.toBoolean(new Integer(null)) = null
|
||||
* BooleanUtils.toBoolean(Integer.valueOf(0)) = Boolean.FALSE
|
||||
* BooleanUtils.toBoolean(Integer.valueOf(1)) = Boolean.TRUE
|
||||
* BooleanUtils.toBoolean(Integer.valueOf(null)) = null
|
||||
* </pre>
|
||||
*
|
||||
* @param value the Integer to convert
|
||||
|
@ -273,11 +273,11 @@ public class BooleanUtils {
|
|||
* <p>Converts an Integer to a boolean specifying the conversion values.</p>
|
||||
*
|
||||
* <pre>
|
||||
* BooleanUtils.toBoolean(new Integer(0), new Integer(1), new Integer(0)) = false
|
||||
* BooleanUtils.toBoolean(new Integer(1), new Integer(1), new Integer(0)) = true
|
||||
* BooleanUtils.toBoolean(new Integer(2), new Integer(1), new Integer(2)) = false
|
||||
* BooleanUtils.toBoolean(new Integer(2), new Integer(2), new Integer(0)) = true
|
||||
* BooleanUtils.toBoolean(null, null, new Integer(0)) = true
|
||||
* BooleanUtils.toBoolean(Integer.valueOf(0), Integer.valueOf(1), Integer.valueOf(0)) = false
|
||||
* BooleanUtils.toBoolean(Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(0)) = true
|
||||
* BooleanUtils.toBoolean(Integer.valueOf(2), Integer.valueOf(1), Integer.valueOf(2)) = false
|
||||
* BooleanUtils.toBoolean(Integer.valueOf(2), Integer.valueOf(2), Integer.valueOf(0)) = true
|
||||
* BooleanUtils.toBoolean(null, null, Integer.valueOf(0)) = true
|
||||
* </pre>
|
||||
*
|
||||
* @param value the Integer to convert
|
||||
|
@ -341,9 +341,9 @@ public class BooleanUtils {
|
|||
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
|
||||
*
|
||||
* <pre>
|
||||
* BooleanUtils.toBooleanObject(new Integer(0), new Integer(0), new Integer(2), new Integer(3)) = Boolean.TRUE
|
||||
* BooleanUtils.toBooleanObject(new Integer(2), new Integer(1), new Integer(2), new Integer(3)) = Boolean.FALSE
|
||||
* BooleanUtils.toBooleanObject(new Integer(3), new Integer(1), new Integer(2), new Integer(3)) = null
|
||||
* BooleanUtils.toBooleanObject(Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(2), Integer.valueOf(3)) = Boolean.TRUE
|
||||
* BooleanUtils.toBooleanObject(Integer.valueOf(2), Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)) = Boolean.FALSE
|
||||
* BooleanUtils.toBooleanObject(Integer.valueOf(3), Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)) = null
|
||||
* </pre>
|
||||
*
|
||||
* @param value the Integer to convert
|
||||
|
@ -398,8 +398,8 @@ public class BooleanUtils {
|
|||
* {@code zero} is {@code false}.</p>
|
||||
*
|
||||
* <pre>
|
||||
* BooleanUtils.toIntegerObject(true) = new Integer(1)
|
||||
* BooleanUtils.toIntegerObject(false) = new Integer(0)
|
||||
* BooleanUtils.toIntegerObject(true) = Integer.valueOf(1)
|
||||
* BooleanUtils.toIntegerObject(false) = Integer.valueOf(0)
|
||||
* </pre>
|
||||
*
|
||||
* @param bool the boolean to convert
|
||||
|
@ -416,8 +416,8 @@ public class BooleanUtils {
|
|||
* <p>{@code null} will be converted to {@code null}.</p>
|
||||
*
|
||||
* <pre>
|
||||
* BooleanUtils.toIntegerObject(Boolean.TRUE) = new Integer(1)
|
||||
* BooleanUtils.toIntegerObject(Boolean.FALSE) = new Integer(0)
|
||||
* BooleanUtils.toIntegerObject(Boolean.TRUE) = Integer.valueOf(1)
|
||||
* BooleanUtils.toIntegerObject(Boolean.FALSE) = Integer.valueOf(0)
|
||||
* </pre>
|
||||
*
|
||||
* @param bool the Boolean to convert
|
||||
|
@ -473,8 +473,8 @@ public class BooleanUtils {
|
|||
* <p>Converts a boolean to an Integer specifying the conversion values.</p>
|
||||
*
|
||||
* <pre>
|
||||
* BooleanUtils.toIntegerObject(true, new Integer(1), new Integer(0)) = new Integer(1)
|
||||
* BooleanUtils.toIntegerObject(false, new Integer(1), new Integer(0)) = new Integer(0)
|
||||
* BooleanUtils.toIntegerObject(true, Integer.valueOf(1), Integer.valueOf(0)) = Integer.valueOf(1)
|
||||
* BooleanUtils.toIntegerObject(false, Integer.valueOf(1), Integer.valueOf(0)) = Integer.valueOf(0)
|
||||
* </pre>
|
||||
*
|
||||
* @param bool the to convert
|
||||
|
@ -490,9 +490,9 @@ public class BooleanUtils {
|
|||
* <p>Converts a Boolean to an Integer specifying the conversion values.</p>
|
||||
*
|
||||
* <pre>
|
||||
* BooleanUtils.toIntegerObject(Boolean.TRUE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(1)
|
||||
* BooleanUtils.toIntegerObject(Boolean.FALSE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(0)
|
||||
* BooleanUtils.toIntegerObject(null, new Integer(1), new Integer(0), new Integer(2)) = new Integer(2)
|
||||
* BooleanUtils.toIntegerObject(Boolean.TRUE, Integer.valueOf(1), Integer.valueOf(0), Integer.valueOf(2)) = Integer.valueOf(1)
|
||||
* BooleanUtils.toIntegerObject(Boolean.FALSE, Integer.valueOf(1), Integer.valueOf(0), Integer.valueOf(2)) = Integer.valueOf(0)
|
||||
* BooleanUtils.toIntegerObject(null, Integer.valueOf(1), Integer.valueOf(0), Integer.valueOf(2)) = Integer.valueOf(2)
|
||||
* </pre>
|
||||
*
|
||||
* @param bool the Boolean to convert
|
||||
|
|
|
@ -36,11 +36,11 @@ public class NumberUtils {
|
|||
/** Reusable Long constant for minus one. */
|
||||
public static final Long LONG_MINUS_ONE = new Long(-1L);
|
||||
/** Reusable Integer constant for zero. */
|
||||
public static final Integer INTEGER_ZERO = new Integer(0);
|
||||
public static final Integer INTEGER_ZERO = Integer.valueOf(0);
|
||||
/** Reusable Integer constant for one. */
|
||||
public static final Integer INTEGER_ONE = new Integer(1);
|
||||
public static final Integer INTEGER_ONE = Integer.valueOf(1);
|
||||
/** Reusable Integer constant for minus one. */
|
||||
public static final Integer INTEGER_MINUS_ONE = new Integer(-1);
|
||||
public static final Integer INTEGER_MINUS_ONE = Integer.valueOf(-1);
|
||||
/** Reusable Short constant for zero. */
|
||||
public static final Short SHORT_ZERO = new Short((short) 0);
|
||||
/** Reusable Short constant for one. */
|
||||
|
@ -395,7 +395,7 @@ public class NumberUtils {
|
|||
// Integer.getInteger(String)
|
||||
// Integer.getInteger(String,int val)
|
||||
// Integer.getInteger(String,Integer val)
|
||||
// new Integer(String)
|
||||
// Integer.valueOf(String)
|
||||
// new Double(String)
|
||||
// new Byte(String)
|
||||
// new Long(String)
|
||||
|
|
|
@ -82,7 +82,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl
|
|||
* @return the value as a Integer, never null
|
||||
*/
|
||||
public Integer getValue() {
|
||||
return new Integer(this.value);
|
||||
return Integer.valueOf(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2514,7 +2514,7 @@ public class StrBuilder implements CharSequence, Appendable {
|
|||
// size = -1;
|
||||
// nullText = null;
|
||||
// return (String) con.newInstance(
|
||||
// new Object[] {new Integer(0), new Integer(size), buffer});
|
||||
// new Object[] {Integer.valueOf(0), Integer.valueOf(size), buffer});
|
||||
//
|
||||
// } catch (Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
|
|
|
@ -122,7 +122,7 @@ public abstract class StrLookup<V> {
|
|||
* the underlying data, by converting it as necessary. For example:
|
||||
* <pre>
|
||||
* Map<String, Object> map = new HashMap<String, Object>();
|
||||
* map.put("number", new Integer(2));
|
||||
* map.put("number", Integer.valueOf(2));
|
||||
* assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
|
||||
* </pre>
|
||||
* @param key the key to be looked up, may be null
|
||||
|
|
|
@ -199,9 +199,9 @@ public class ArrayUtilsAddTest extends TestCase {
|
|||
assertTrue(Arrays.equals((new String[]{"a", "b", "c", "d"}), newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
|
||||
Number[] numberArray1 = new Number[]{new Integer(1), new Double(2)};
|
||||
Number[] numberArray1 = new Number[]{Integer.valueOf(1), new Double(2)};
|
||||
newArray = ArrayUtils.add(numberArray1, new Float(3));
|
||||
assertTrue(Arrays.equals((new Number[]{new Integer(1), new Double(2), new Float(3)}), newArray));
|
||||
assertTrue(Arrays.equals((new Number[]{Integer.valueOf(1), new Double(2), new Float(3)}), newArray));
|
||||
assertEquals(Number.class, newArray.getClass().getComponentType());
|
||||
|
||||
numberArray1 = null;
|
||||
|
|
|
@ -2491,12 +2491,12 @@ public class ArrayUtilsTest extends TestCase {
|
|||
assertSame(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.toPrimitive(new Integer[0]));
|
||||
assertTrue(Arrays.equals(
|
||||
new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
|
||||
ArrayUtils.toPrimitive(new Integer[] {new Integer(Integer.MIN_VALUE),
|
||||
new Integer(Integer.MAX_VALUE), new Integer(9999999)}))
|
||||
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE),
|
||||
Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)}))
|
||||
);
|
||||
|
||||
try {
|
||||
ArrayUtils.toPrimitive(new Integer[] {new Integer(Integer.MIN_VALUE), null});
|
||||
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), null});
|
||||
fail();
|
||||
} catch (NullPointerException ex) {}
|
||||
}
|
||||
|
@ -2508,12 +2508,12 @@ public class ArrayUtilsTest extends TestCase {
|
|||
ArrayUtils.toPrimitive(new Integer[0], 1));
|
||||
assertTrue(Arrays.equals(
|
||||
new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
|
||||
ArrayUtils.toPrimitive(new Integer[] {new Integer(Integer.MIN_VALUE),
|
||||
new Integer(Integer.MAX_VALUE), new Integer(9999999)},1)));
|
||||
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE),
|
||||
Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)},1)));
|
||||
assertTrue(Arrays.equals(
|
||||
new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
|
||||
ArrayUtils.toPrimitive(new Integer[] {new Integer(Integer.MIN_VALUE),
|
||||
null, new Integer(9999999)}, Integer.MAX_VALUE))
|
||||
ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE),
|
||||
null, Integer.valueOf(9999999)}, Integer.MAX_VALUE))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2533,9 +2533,9 @@ public class ArrayUtilsTest extends TestCase {
|
|||
assertTrue(
|
||||
Arrays.equals(
|
||||
new Integer[] {
|
||||
new Integer(Integer.MIN_VALUE),
|
||||
new Integer(Integer.MAX_VALUE),
|
||||
new Integer(9999999)},
|
||||
Integer.valueOf(Integer.MIN_VALUE),
|
||||
Integer.valueOf(Integer.MAX_VALUE),
|
||||
Integer.valueOf(9999999)},
|
||||
ArrayUtils.toObject(
|
||||
new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999 })));
|
||||
}
|
||||
|
|
|
@ -115,9 +115,9 @@ public class BooleanUtilsTest {
|
|||
|
||||
@Test
|
||||
public void test_toBooleanObject_Integer() {
|
||||
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(1)));
|
||||
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(-1)));
|
||||
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(0)));
|
||||
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(1)));
|
||||
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(-1)));
|
||||
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(0)));
|
||||
assertEquals(null, BooleanUtils.toBooleanObject((Integer) null));
|
||||
}
|
||||
|
||||
|
@ -135,14 +135,14 @@ public class BooleanUtilsTest {
|
|||
|
||||
@Test
|
||||
public void test_toBoolean_Integer_Integer_Integer() {
|
||||
Integer six = new Integer(6);
|
||||
Integer seven = new Integer(7);
|
||||
Integer six = Integer.valueOf(6);
|
||||
Integer seven = Integer.valueOf(7);
|
||||
|
||||
assertEquals(true, BooleanUtils.toBoolean((Integer) null, null, seven));
|
||||
assertEquals(false, BooleanUtils.toBoolean((Integer) null, six, null));
|
||||
|
||||
assertEquals(true, BooleanUtils.toBoolean(new Integer(6), six, seven));
|
||||
assertEquals(false, BooleanUtils.toBoolean(new Integer(7), six, seven));
|
||||
assertEquals(true, BooleanUtils.toBoolean(Integer.valueOf(6), six, seven));
|
||||
assertEquals(false, BooleanUtils.toBoolean(Integer.valueOf(7), six, seven));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
@ -152,7 +152,7 @@ public class BooleanUtilsTest {
|
|||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void test_toBoolean_Integer_Integer_Integer_noMatch() {
|
||||
BooleanUtils.toBoolean(new Integer(8), Integer.valueOf(6), Integer.valueOf(7));
|
||||
BooleanUtils.toBoolean(Integer.valueOf(8), Integer.valueOf(6), Integer.valueOf(7));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -170,17 +170,17 @@ public class BooleanUtilsTest {
|
|||
|
||||
@Test
|
||||
public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
|
||||
Integer six = new Integer(6);
|
||||
Integer seven = new Integer(7);
|
||||
Integer eight = new Integer(8);
|
||||
Integer six = Integer.valueOf(6);
|
||||
Integer seven = Integer.valueOf(7);
|
||||
Integer eight = Integer.valueOf(8);
|
||||
|
||||
assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight));
|
||||
assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight));
|
||||
assertSame(null, BooleanUtils.toBooleanObject((Integer) null, six, seven, null));
|
||||
|
||||
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(6), six, seven, eight));
|
||||
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(7), six, seven, eight));
|
||||
assertEquals(null, BooleanUtils.toBooleanObject(new Integer(8), six, seven, eight));
|
||||
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(6), six, seven, eight));
|
||||
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(7), six, seven, eight));
|
||||
assertEquals(null, BooleanUtils.toBooleanObject(Integer.valueOf(8), six, seven, eight));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
@ -202,14 +202,14 @@ public class BooleanUtilsTest {
|
|||
|
||||
@Test
|
||||
public void test_toIntegerObject_boolean() {
|
||||
assertEquals(new Integer(1), BooleanUtils.toIntegerObject(true));
|
||||
assertEquals(new Integer(0), BooleanUtils.toIntegerObject(false));
|
||||
assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(true));
|
||||
assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toIntegerObject_Boolean() {
|
||||
assertEquals(new Integer(1), BooleanUtils.toIntegerObject(Boolean.TRUE));
|
||||
assertEquals(new Integer(0), BooleanUtils.toIntegerObject(Boolean.FALSE));
|
||||
assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(Boolean.TRUE));
|
||||
assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(Boolean.FALSE));
|
||||
assertEquals(null, BooleanUtils.toIntegerObject((Boolean) null));
|
||||
}
|
||||
|
||||
|
@ -229,17 +229,17 @@ public class BooleanUtilsTest {
|
|||
|
||||
@Test
|
||||
public void test_toIntegerObject_boolean_Integer_Integer() {
|
||||
Integer six = new Integer(6);
|
||||
Integer seven = new Integer(7);
|
||||
Integer six = Integer.valueOf(6);
|
||||
Integer seven = Integer.valueOf(7);
|
||||
assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven));
|
||||
assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toIntegerObject_Boolean_Integer_Integer_Integer() {
|
||||
Integer six = new Integer(6);
|
||||
Integer seven = new Integer(7);
|
||||
Integer eight = new Integer(8);
|
||||
Integer six = Integer.valueOf(6);
|
||||
Integer seven = Integer.valueOf(7);
|
||||
Integer eight = Integer.valueOf(8);
|
||||
assertEquals(six, BooleanUtils.toIntegerObject(Boolean.TRUE, six, seven, eight));
|
||||
assertEquals(seven, BooleanUtils.toIntegerObject(Boolean.FALSE, six, seven, eight));
|
||||
assertEquals(eight, BooleanUtils.toIntegerObject((Boolean) null, six, seven, eight));
|
||||
|
|
|
@ -177,7 +177,7 @@ public class ObjectUtilsTest {
|
|||
assertEquals(
|
||||
"java.lang.String@" + Integer.toHexString(System.identityHashCode(FOO)),
|
||||
ObjectUtils.identityToString(FOO));
|
||||
Integer i = new Integer(90);
|
||||
Integer i = Integer.valueOf(90);
|
||||
String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));
|
||||
assertEquals(expected, ObjectUtils.identityToString(i));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
|
|
@ -53,7 +53,7 @@ public class SerializationUtilsTest extends TestCase {
|
|||
super.setUp();
|
||||
|
||||
iString = "foo";
|
||||
iInteger = new Integer(7);
|
||||
iInteger = Integer.valueOf(7);
|
||||
iMap = new HashMap<Object, Object>();
|
||||
iMap.put("FOO", iString);
|
||||
iMap.put("BAR", iInteger);
|
||||
|
|
|
@ -65,9 +65,9 @@ public class ValidateTest extends TestCase {
|
|||
|
||||
//-----------------------------------------------------------------------
|
||||
public void testIsTrue3() {
|
||||
Validate.isTrue(true, "MSG", new Integer(6));
|
||||
Validate.isTrue(true, "MSG", Integer.valueOf(6));
|
||||
try {
|
||||
Validate.isTrue(false, "MSG", new Integer(6));
|
||||
Validate.isTrue(false, "MSG", Integer.valueOf(6));
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
assertEquals("MSG", ex.getMessage());
|
||||
|
@ -186,7 +186,7 @@ public class ValidateTest extends TestCase {
|
|||
} catch (IllegalArgumentException ex) {
|
||||
assertEquals("The validated collection is empty", ex.getMessage());
|
||||
}
|
||||
coll.add(new Integer(8));
|
||||
coll.add(Integer.valueOf(8));
|
||||
Validate.notEmpty(coll);
|
||||
|
||||
Collection<Integer> test = Validate.notEmpty(coll);
|
||||
|
@ -208,7 +208,7 @@ public class ValidateTest extends TestCase {
|
|||
} catch (IllegalArgumentException ex) {
|
||||
assertEquals("MSG", ex.getMessage());
|
||||
}
|
||||
coll.add(new Integer(8));
|
||||
coll.add(Integer.valueOf(8));
|
||||
Validate.notEmpty(coll, "MSG");
|
||||
|
||||
Collection<Integer> test = Validate.notEmpty(coll, "Message");
|
||||
|
@ -231,7 +231,7 @@ public class ValidateTest extends TestCase {
|
|||
} catch (IllegalArgumentException ex) {
|
||||
assertEquals("The validated map is empty", ex.getMessage());
|
||||
}
|
||||
map.put("ll", new Integer(8));
|
||||
map.put("ll", Integer.valueOf(8));
|
||||
Validate.notEmpty(map);
|
||||
|
||||
Map<String, Integer> test = Validate.notEmpty(map);
|
||||
|
@ -253,7 +253,7 @@ public class ValidateTest extends TestCase {
|
|||
} catch (IllegalArgumentException ex) {
|
||||
assertEquals("MSG", ex.getMessage());
|
||||
}
|
||||
map.put("ll", new Integer(8));
|
||||
map.put("ll", Integer.valueOf(8));
|
||||
Validate.notEmpty(map, "MSG");
|
||||
|
||||
Map<String, Integer> test = Validate.notEmpty(map, "Message");
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.lang3.builder.ToStringStyleTest.Person;
|
|||
*/
|
||||
public class DefaultToStringStyleTest extends TestCase {
|
||||
|
||||
private final Integer base = new Integer(5);
|
||||
private final Integer base = Integer.valueOf(5);
|
||||
private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base));
|
||||
|
||||
public DefaultToStringStyleTest(String name) {
|
||||
|
@ -65,8 +65,8 @@ public class DefaultToStringStyleTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testObject() {
|
||||
Integer i3 = new Integer(3);
|
||||
Integer i4 = new Integer(4);
|
||||
Integer i3 = Integer.valueOf(3);
|
||||
Integer i4 = Integer.valueOf(4);
|
||||
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
|
||||
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
|
||||
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
|
||||
|
|
|
@ -957,8 +957,8 @@ public class EqualsBuilderTest extends TestCase {
|
|||
* Test from http://issues.apache.org/bugzilla/show_bug.cgi?id=33067
|
||||
*/
|
||||
public void testNpeForNullElement() {
|
||||
Object[] x1 = new Object[] { new Integer(1), null, new Integer(3) };
|
||||
Object[] x2 = new Object[] { new Integer(1), new Integer(2), new Integer(3) };
|
||||
Object[] x1 = new Object[] { Integer.valueOf(1), null, Integer.valueOf(3) };
|
||||
Object[] x2 = new Object[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
|
||||
|
||||
// causes an NPE in 2.0 according to:
|
||||
// http://issues.apache.org/bugzilla/show_bug.cgi?id=33067
|
||||
|
|
|
@ -38,8 +38,8 @@ public class HashCodeBuilderAndEqualsBuilderTest extends TestCase {
|
|||
//-----------------------------------------------------------------------
|
||||
|
||||
public void testInteger(boolean testTransients) {
|
||||
Integer i1 = new Integer(12345);
|
||||
Integer i2 = new Integer(12345);
|
||||
Integer i1 = Integer.valueOf(12345);
|
||||
Integer i2 = Integer.valueOf(12345);
|
||||
assertEqualsAndHashCodeContract(i1, i2, testTransients);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.lang3.builder.ToStringStyleTest.Person;
|
|||
*/
|
||||
public class MultiLineToStringStyleTest extends TestCase {
|
||||
|
||||
private final Integer base = new Integer(5);
|
||||
private final Integer base = Integer.valueOf(5);
|
||||
private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base));
|
||||
|
||||
public MultiLineToStringStyleTest(String name) {
|
||||
|
@ -66,8 +66,8 @@ public class MultiLineToStringStyleTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testObject() {
|
||||
Integer i3 = new Integer(3);
|
||||
Integer i4 = new Integer(4);
|
||||
Integer i3 = Integer.valueOf(3);
|
||||
Integer i4 = Integer.valueOf(4);
|
||||
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) null).toString());
|
||||
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " 3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(i3).toString());
|
||||
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) null).toString());
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.lang3.builder.ToStringStyleTest.Person;
|
|||
*/
|
||||
public class NoFieldNamesToStringStyleTest extends TestCase {
|
||||
|
||||
private final Integer base = new Integer(5);
|
||||
private final Integer base = Integer.valueOf(5);
|
||||
private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base));
|
||||
|
||||
public NoFieldNamesToStringStyleTest(String name) {
|
||||
|
@ -65,8 +65,8 @@ public class NoFieldNamesToStringStyleTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testObject() {
|
||||
Integer i3 = new Integer(3);
|
||||
Integer i4 = new Integer(4);
|
||||
Integer i3 = Integer.valueOf(3);
|
||||
Integer i4 = Integer.valueOf(4);
|
||||
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
|
||||
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
|
||||
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.lang3.builder.ToStringStyleTest.Person;
|
|||
*/
|
||||
public class ShortPrefixToStringStyleTest extends TestCase {
|
||||
|
||||
private final Integer base = new Integer(5);
|
||||
private final Integer base = Integer.valueOf(5);
|
||||
private final String baseStr = "Integer";
|
||||
|
||||
@Override
|
||||
|
@ -61,8 +61,8 @@ public class ShortPrefixToStringStyleTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testObject() {
|
||||
Integer i3 = new Integer(3);
|
||||
Integer i4 = new Integer(4);
|
||||
Integer i3 = Integer.valueOf(3);
|
||||
Integer i4 = Integer.valueOf(4);
|
||||
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
|
||||
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
|
||||
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.lang3.builder.ToStringStyleTest.Person;
|
|||
*/
|
||||
public class SimpleToStringStyleTest extends TestCase {
|
||||
|
||||
private final Integer base = new Integer(5);
|
||||
private final Integer base = Integer.valueOf(5);
|
||||
|
||||
public SimpleToStringStyleTest(String name) {
|
||||
super(name);
|
||||
|
@ -64,8 +64,8 @@ public class SimpleToStringStyleTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testObject() {
|
||||
Integer i3 = new Integer(3);
|
||||
Integer i4 = new Integer(4);
|
||||
Integer i3 = Integer.valueOf(3);
|
||||
Integer i4 = Integer.valueOf(4);
|
||||
assertEquals("<null>", new ToStringBuilder(base).append((Object) null).toString());
|
||||
assertEquals("3", new ToStringBuilder(base).append(i3).toString());
|
||||
assertEquals("<null>", new ToStringBuilder(base).append("a", (Object) null).toString());
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.lang3.builder.ToStringStyleTest.Person;
|
|||
*/
|
||||
public class StandardToStringStyleTest extends TestCase {
|
||||
|
||||
private final Integer base = new Integer(5);
|
||||
private final Integer base = Integer.valueOf(5);
|
||||
private final String baseStr = "Integer";
|
||||
|
||||
private static final StandardToStringStyle STYLE = new StandardToStringStyle();
|
||||
|
@ -80,8 +80,8 @@ public class StandardToStringStyleTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testObject() {
|
||||
Integer i3 = new Integer(3);
|
||||
Integer i4 = new Integer(4);
|
||||
Integer i3 = Integer.valueOf(3);
|
||||
Integer i4 = Integer.valueOf(4);
|
||||
assertEquals(baseStr + "[%NULL%]", new ToStringBuilder(base).append((Object) null).toString());
|
||||
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
|
||||
assertEquals(baseStr + "[a=%NULL%]", new ToStringBuilder(base).append("a", (Object) null).toString());
|
||||
|
|
|
@ -601,8 +601,8 @@ public class ToStringBuilderTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testObject() {
|
||||
Integer i3 = new Integer(3);
|
||||
Integer i4 = new Integer(4);
|
||||
Integer i3 = Integer.valueOf(3);
|
||||
Integer i4 = Integer.valueOf(4);
|
||||
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString());
|
||||
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString());
|
||||
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString());
|
||||
|
@ -618,8 +618,8 @@ public class ToStringBuilderTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testObjectBuild() {
|
||||
Integer i3 = new Integer(3);
|
||||
Integer i4 = new Integer(4);
|
||||
Integer i3 = Integer.valueOf(3);
|
||||
Integer i4 = Integer.valueOf(4);
|
||||
assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).build());
|
||||
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).build());
|
||||
assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).build());
|
||||
|
@ -945,7 +945,7 @@ public class ToStringBuilderTest extends TestCase {
|
|||
* Tests ReflectionToStringBuilder setUpToClass().
|
||||
*/
|
||||
public void test_setUpToClass_valid() {
|
||||
Integer val = new Integer(5);
|
||||
Integer val = Integer.valueOf(5);
|
||||
ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
|
||||
test.setUpToClass(Number.class);
|
||||
}
|
||||
|
@ -954,7 +954,7 @@ public class ToStringBuilderTest extends TestCase {
|
|||
* Tests ReflectionToStringBuilder setUpToClass().
|
||||
*/
|
||||
public void test_setUpToClass_invalid() {
|
||||
Integer val = new Integer(5);
|
||||
Integer val = Integer.valueOf(5);
|
||||
ReflectionToStringBuilder test = new ReflectionToStringBuilder(val);
|
||||
try {
|
||||
test.setUpToClass(String.class);
|
||||
|
@ -1003,7 +1003,7 @@ public class ToStringBuilderTest extends TestCase {
|
|||
* See issue LANG-372.
|
||||
*/
|
||||
class MultiLineTestObject {
|
||||
Integer i = new Integer(31337);
|
||||
Integer i = Integer.valueOf(31337);
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this).append("testInt", i).toString();
|
||||
|
|
|
@ -380,7 +380,7 @@ public class ConcurrentUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
public void testConstantFuture_Integer() throws Exception {
|
||||
Integer value = new Integer(5);
|
||||
Integer value = Integer.valueOf(5);
|
||||
Future<Integer> test = ConcurrentUtils.constantFuture(value);
|
||||
assertTrue(test.isDone());
|
||||
assertSame(value, test.get());
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ConstantInitializerTest {
|
|||
public void testEqualsTrue() {
|
||||
checkEquals(init, true);
|
||||
ConstantInitializer<Integer> init2 = new ConstantInitializer<Integer>(
|
||||
new Integer(VALUE.intValue()));
|
||||
Integer.valueOf(VALUE.intValue()));
|
||||
checkEquals(init2, true);
|
||||
init = new ConstantInitializer<Integer>(null);
|
||||
init2 = new ConstantInitializer<Integer>(null);
|
||||
|
|
|
@ -51,7 +51,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
|
|||
.addContextValue("test1", null)
|
||||
.addContextValue("test2", "some value")
|
||||
.addContextValue("test Date", new Date())
|
||||
.addContextValue("test Nbr", new Integer(5))
|
||||
.addContextValue("test Nbr", Integer.valueOf(5))
|
||||
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
|
|||
.addContextValue("test1", null)
|
||||
.addContextValue("test2", "some value")
|
||||
.addContextValue("test Date", new Date())
|
||||
.addContextValue("test Nbr", new Integer(5))
|
||||
.addContextValue("test Nbr", Integer.valueOf(5))
|
||||
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
|
||||
|
||||
String message = exceptionContext.getMessage();
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
|
|||
.addContextValue("test1", null)
|
||||
.addContextValue("test2", "some value")
|
||||
.addContextValue("test Date", new Date())
|
||||
.addContextValue("test Nbr", new Integer(5))
|
||||
.addContextValue("test Nbr", Integer.valueOf(5))
|
||||
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
|
||||
|
||||
String message = exceptionContext.getMessage();
|
||||
|
|
|
@ -1220,7 +1220,7 @@ public class FractionTest extends TestCase {
|
|||
f1 = Fraction.getFraction(3, 5);
|
||||
assertEquals(false, f1.equals(null));
|
||||
assertEquals(false, f1.equals(new Object()));
|
||||
assertEquals(false, f1.equals(new Integer(6)));
|
||||
assertEquals(false, f1.equals(Integer.valueOf(6)));
|
||||
|
||||
f1 = Fraction.getFraction(3, 5);
|
||||
f2 = Fraction.getFraction(2, 5);
|
||||
|
|
|
@ -182,7 +182,7 @@ public class NumberUtilsTest {
|
|||
public void testCreateNumber() {
|
||||
// a lot of things can go wrong
|
||||
assertEquals("createNumber(String) 1 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5"));
|
||||
assertEquals("createNumber(String) 2 failed", new Integer("12345"), NumberUtils.createNumber("12345"));
|
||||
assertEquals("createNumber(String) 2 failed", Integer.valueOf("12345"), NumberUtils.createNumber("12345"));
|
||||
assertEquals("createNumber(String) 3 failed", new Double("1234.5"), NumberUtils.createNumber("1234.5D"));
|
||||
assertEquals("createNumber(String) 3 failed", new Double("1234.5"), NumberUtils.createNumber("1234.5d"));
|
||||
assertEquals("createNumber(String) 4 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5F"));
|
||||
|
@ -192,7 +192,7 @@ public class NumberUtilsTest {
|
|||
assertEquals("createNumber(String) 6 failed", new Long(12345), NumberUtils.createNumber("12345L"));
|
||||
assertEquals("createNumber(String) 6 failed", new Long(12345), NumberUtils.createNumber("12345l"));
|
||||
assertEquals("createNumber(String) 7 failed", new Float("-1234.5"), NumberUtils.createNumber("-1234.5"));
|
||||
assertEquals("createNumber(String) 8 failed", new Integer("-12345"), NumberUtils.createNumber("-12345"));
|
||||
assertEquals("createNumber(String) 8 failed", Integer.valueOf("-12345"), NumberUtils.createNumber("-12345"));
|
||||
assertTrue("createNumber(String) 9 failed", 0xFADE == NumberUtils.createNumber("0xFADE").intValue());
|
||||
assertTrue("createNumber(String) 10 failed", -0xFADE == NumberUtils.createNumber("-0xFADE").intValue());
|
||||
assertEquals("createNumber(String) 11 failed", new Double("1.1E200"), NumberUtils.createNumber("1.1E200"));
|
||||
|
@ -268,7 +268,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testCreateInteger() {
|
||||
assertEquals("createInteger(String) failed", new Integer("12345"), NumberUtils.createInteger("12345"));
|
||||
assertEquals("createInteger(String) failed", Integer.valueOf("12345"), NumberUtils.createInteger("12345"));
|
||||
assertEquals("createInteger(null) failed", null, NumberUtils.createInteger(null));
|
||||
this.testCreateIntegerFailure("");
|
||||
this.testCreateIntegerFailure(" ");
|
||||
|
|
|
@ -150,7 +150,7 @@ public class MutableByteTest extends TestCase {
|
|||
|
||||
public void testAddValueObject() {
|
||||
MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.add(new Integer(1));
|
||||
mutNum.add(Integer.valueOf(1));
|
||||
|
||||
assertEquals((byte) 2, mutNum.byteValue());
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class MutableByteTest extends TestCase {
|
|||
|
||||
public void testSubtractValueObject() {
|
||||
MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.subtract(new Integer(1));
|
||||
mutNum.subtract(Integer.valueOf(1));
|
||||
|
||||
assertEquals((byte) 0, mutNum.byteValue());
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class MutableIntTest extends TestCase {
|
|||
|
||||
assertEquals(1, new MutableInt(1).intValue());
|
||||
|
||||
assertEquals(2, new MutableInt(new Integer(2)).intValue());
|
||||
assertEquals(2, new MutableInt(Integer.valueOf(2)).intValue());
|
||||
assertEquals(3, new MutableInt(new MutableLong(3)).intValue());
|
||||
|
||||
assertEquals(2, new MutableInt("2").intValue());
|
||||
|
@ -50,19 +50,19 @@ public class MutableIntTest extends TestCase {
|
|||
public void testGetSet() {
|
||||
final MutableInt mutNum = new MutableInt(0);
|
||||
assertEquals(0, new MutableInt().intValue());
|
||||
assertEquals(new Integer(0), new MutableInt().getValue());
|
||||
assertEquals(Integer.valueOf(0), new MutableInt().getValue());
|
||||
|
||||
mutNum.setValue(1);
|
||||
assertEquals(1, mutNum.intValue());
|
||||
assertEquals(new Integer(1), mutNum.getValue());
|
||||
assertEquals(Integer.valueOf(1), mutNum.getValue());
|
||||
|
||||
mutNum.setValue(new Integer(2));
|
||||
mutNum.setValue(Integer.valueOf(2));
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(new Integer(2), mutNum.getValue());
|
||||
assertEquals(Integer.valueOf(2), mutNum.getValue());
|
||||
|
||||
mutNum.setValue(new MutableLong(3));
|
||||
assertEquals(3, mutNum.intValue());
|
||||
assertEquals(new Integer(3), mutNum.getValue());
|
||||
assertEquals(Integer.valueOf(3), mutNum.getValue());
|
||||
try {
|
||||
mutNum.setValue(null);
|
||||
fail();
|
||||
|
@ -72,7 +72,7 @@ public class MutableIntTest extends TestCase {
|
|||
public void testEquals() {
|
||||
this.testEquals(new MutableInt(0), new MutableInt(0), new MutableInt(1));
|
||||
// Should Numbers be supported? GaryG July-21-2005.
|
||||
//this.testEquals(mutNumA, new Integer(0), mutNumC);
|
||||
//this.testEquals(mutNumA, Integer.valueOf(0), mutNumC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ public class MutableIntTest extends TestCase {
|
|||
assertEquals(false, numB.equals(numC));
|
||||
assertEquals(true, numC.equals(numC));
|
||||
assertEquals(false, numA.equals(null));
|
||||
assertEquals(false, numA.equals(new Integer(0)));
|
||||
assertEquals(false, numA.equals(Integer.valueOf(0)));
|
||||
assertEquals(false, numA.equals("0"));
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class MutableIntTest extends TestCase {
|
|||
assertEquals(true, mutNumA.hashCode() == mutNumA.hashCode());
|
||||
assertEquals(true, mutNumA.hashCode() == mutNumB.hashCode());
|
||||
assertEquals(false, mutNumA.hashCode() == mutNumC.hashCode());
|
||||
assertEquals(true, mutNumA.hashCode() == new Integer(0).hashCode());
|
||||
assertEquals(true, mutNumA.hashCode() == Integer.valueOf(0).hashCode());
|
||||
}
|
||||
|
||||
public void testCompareTo() {
|
||||
|
@ -127,8 +127,8 @@ public class MutableIntTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testToInteger() {
|
||||
assertEquals(new Integer(0), new MutableInt(0).toInteger());
|
||||
assertEquals(new Integer(123), new MutableInt(123).toInteger());
|
||||
assertEquals(Integer.valueOf(0), new MutableInt(0).toInteger());
|
||||
assertEquals(Integer.valueOf(123), new MutableInt(123).toInteger());
|
||||
}
|
||||
|
||||
public void testIncrement() {
|
||||
|
@ -157,7 +157,7 @@ public class MutableIntTest extends TestCase {
|
|||
|
||||
public void testAddValueObject() {
|
||||
MutableInt mutNum = new MutableInt(1);
|
||||
mutNum.add(new Integer(1));
|
||||
mutNum.add(Integer.valueOf(1));
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
|
@ -173,7 +173,7 @@ public class MutableIntTest extends TestCase {
|
|||
|
||||
public void testSubtractValueObject() {
|
||||
MutableInt mutNum = new MutableInt(1);
|
||||
mutNum.subtract(new Integer(1));
|
||||
mutNum.subtract(Integer.valueOf(1));
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
|
|
|
@ -34,7 +34,7 @@ public class MutableObjectTest extends TestCase {
|
|||
public void testConstructors() {
|
||||
assertEquals(null, new MutableObject<String>().getValue());
|
||||
|
||||
Integer i = new Integer(6);
|
||||
Integer i = Integer.valueOf(6);
|
||||
assertSame(i, new MutableObject<Integer>(i).getValue());
|
||||
assertSame("HI", new MutableObject<String>("HI").getValue());
|
||||
assertSame(null, new MutableObject<Object>(null).getValue());
|
||||
|
|
|
@ -44,8 +44,8 @@ public class FieldUtilsTest {
|
|||
|
||||
static final String S = "s";
|
||||
static final String SS = "ss";
|
||||
static final Integer I0 = new Integer(0);
|
||||
static final Integer I1 = new Integer(1);
|
||||
static final Integer I0 = Integer.valueOf(0);
|
||||
static final Integer I1 = Integer.valueOf(1);
|
||||
static final Double D0 = new Double(0.0);
|
||||
static final Double D1 = new Double(1.0);
|
||||
|
||||
|
@ -913,7 +913,7 @@ public class FieldUtilsTest {
|
|||
}
|
||||
field = parentClass.getDeclaredField("i");
|
||||
try {
|
||||
FieldUtils.writeField(field, publicChild, new Integer(Integer.MAX_VALUE));
|
||||
FieldUtils.writeField(field, publicChild, Integer.valueOf(Integer.MAX_VALUE));
|
||||
} catch (IllegalAccessException e) {
|
||||
// pass
|
||||
}
|
||||
|
@ -934,8 +934,8 @@ public class FieldUtilsTest {
|
|||
FieldUtils.writeField(field, publicChild, Boolean.TRUE, true);
|
||||
assertEquals(Boolean.TRUE, field.get(publicChild));
|
||||
field = parentClass.getDeclaredField("i");
|
||||
FieldUtils.writeField(field, publicChild, new Integer(Integer.MAX_VALUE), true);
|
||||
assertEquals(new Integer(Integer.MAX_VALUE), field.get(publicChild));
|
||||
FieldUtils.writeField(field, publicChild, Integer.valueOf(Integer.MAX_VALUE), true);
|
||||
assertEquals(Integer.valueOf(Integer.MAX_VALUE), field.get(publicChild));
|
||||
field = parentClass.getDeclaredField("d");
|
||||
FieldUtils.writeField(field, publicChild, new Double(Double.MAX_VALUE), true);
|
||||
assertEquals(new Double(Double.MAX_VALUE), field.get(publicChild));
|
||||
|
@ -952,7 +952,7 @@ public class FieldUtilsTest {
|
|||
// pass
|
||||
}
|
||||
try {
|
||||
FieldUtils.writeField(publicChild, "i", new Integer(1));
|
||||
FieldUtils.writeField(publicChild, "i", Integer.valueOf(1));
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// pass
|
||||
|
@ -968,8 +968,8 @@ public class FieldUtilsTest {
|
|||
assertEquals("S", FieldUtils.readField(publiclyShadowedChild, "s"));
|
||||
FieldUtils.writeField(publiclyShadowedChild, "b", Boolean.FALSE);
|
||||
assertEquals(Boolean.FALSE, FieldUtils.readField(publiclyShadowedChild, "b"));
|
||||
FieldUtils.writeField(publiclyShadowedChild, "i", new Integer(0));
|
||||
assertEquals(new Integer(0), FieldUtils.readField(publiclyShadowedChild, "i"));
|
||||
FieldUtils.writeField(publiclyShadowedChild, "i", Integer.valueOf(0));
|
||||
assertEquals(Integer.valueOf(0), FieldUtils.readField(publiclyShadowedChild, "i"));
|
||||
FieldUtils.writeField(publiclyShadowedChild, "d", new Double(0.0));
|
||||
assertEquals(new Double(0.0), FieldUtils.readField(publiclyShadowedChild, "d"));
|
||||
|
||||
|
@ -982,7 +982,7 @@ public class FieldUtilsTest {
|
|||
// pass
|
||||
}
|
||||
try {
|
||||
FieldUtils.writeField(privatelyShadowedChild, "i", new Integer(1));
|
||||
FieldUtils.writeField(privatelyShadowedChild, "i", Integer.valueOf(1));
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// pass
|
||||
|
@ -1001,8 +1001,8 @@ public class FieldUtilsTest {
|
|||
assertEquals("S", FieldUtils.readField(publicChild, "s", true));
|
||||
FieldUtils.writeField(publicChild, "b", Boolean.TRUE, true);
|
||||
assertEquals(Boolean.TRUE, FieldUtils.readField(publicChild, "b", true));
|
||||
FieldUtils.writeField(publicChild, "i", new Integer(1), true);
|
||||
assertEquals(new Integer(1), FieldUtils.readField(publicChild, "i", true));
|
||||
FieldUtils.writeField(publicChild, "i", Integer.valueOf(1), true);
|
||||
assertEquals(Integer.valueOf(1), FieldUtils.readField(publicChild, "i", true));
|
||||
FieldUtils.writeField(publicChild, "d", new Double(1.0), true);
|
||||
assertEquals(new Double(1.0), FieldUtils.readField(publicChild, "d", true));
|
||||
|
||||
|
@ -1010,8 +1010,8 @@ public class FieldUtilsTest {
|
|||
assertEquals("S", FieldUtils.readField(publiclyShadowedChild, "s", true));
|
||||
FieldUtils.writeField(publiclyShadowedChild, "b", Boolean.FALSE, true);
|
||||
assertEquals(Boolean.FALSE, FieldUtils.readField(publiclyShadowedChild, "b", true));
|
||||
FieldUtils.writeField(publiclyShadowedChild, "i", new Integer(0), true);
|
||||
assertEquals(new Integer(0), FieldUtils.readField(publiclyShadowedChild, "i", true));
|
||||
FieldUtils.writeField(publiclyShadowedChild, "i", Integer.valueOf(0), true);
|
||||
assertEquals(Integer.valueOf(0), FieldUtils.readField(publiclyShadowedChild, "i", true));
|
||||
FieldUtils.writeField(publiclyShadowedChild, "d", new Double(0.0), true);
|
||||
assertEquals(new Double(0.0), FieldUtils.readField(publiclyShadowedChild, "d", true));
|
||||
|
||||
|
@ -1019,8 +1019,8 @@ public class FieldUtilsTest {
|
|||
assertEquals("S", FieldUtils.readField(privatelyShadowedChild, "s", true));
|
||||
FieldUtils.writeField(privatelyShadowedChild, "b", Boolean.FALSE, true);
|
||||
assertEquals(Boolean.FALSE, FieldUtils.readField(privatelyShadowedChild, "b", true));
|
||||
FieldUtils.writeField(privatelyShadowedChild, "i", new Integer(0), true);
|
||||
assertEquals(new Integer(0), FieldUtils.readField(privatelyShadowedChild, "i", true));
|
||||
FieldUtils.writeField(privatelyShadowedChild, "i", Integer.valueOf(0), true);
|
||||
assertEquals(Integer.valueOf(0), FieldUtils.readField(privatelyShadowedChild, "i", true));
|
||||
FieldUtils.writeField(privatelyShadowedChild, "d", new Double(0.0), true);
|
||||
assertEquals(new Double(0.0), FieldUtils.readField(privatelyShadowedChild, "d", true));
|
||||
}
|
||||
|
@ -1040,7 +1040,7 @@ public class FieldUtilsTest {
|
|||
// pass
|
||||
}
|
||||
try {
|
||||
FieldUtils.writeDeclaredField(publicChild, "i", new Integer(1));
|
||||
FieldUtils.writeDeclaredField(publicChild, "i", Integer.valueOf(1));
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// pass
|
||||
|
@ -1056,8 +1056,8 @@ public class FieldUtilsTest {
|
|||
assertEquals("S", FieldUtils.readDeclaredField(publiclyShadowedChild, "s"));
|
||||
FieldUtils.writeDeclaredField(publiclyShadowedChild, "b", Boolean.FALSE);
|
||||
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b"));
|
||||
FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", new Integer(0));
|
||||
assertEquals(new Integer(0), FieldUtils.readDeclaredField(publiclyShadowedChild, "i"));
|
||||
FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", Integer.valueOf(0));
|
||||
assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(publiclyShadowedChild, "i"));
|
||||
FieldUtils.writeDeclaredField(publiclyShadowedChild, "d", new Double(0.0));
|
||||
assertEquals(new Double(0.0), FieldUtils.readDeclaredField(publiclyShadowedChild, "d"));
|
||||
|
||||
|
@ -1074,7 +1074,7 @@ public class FieldUtilsTest {
|
|||
// pass
|
||||
}
|
||||
try {
|
||||
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", new Integer(1));
|
||||
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", Integer.valueOf(1));
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// pass
|
||||
|
@ -1102,7 +1102,7 @@ public class FieldUtilsTest {
|
|||
// pass
|
||||
}
|
||||
try {
|
||||
FieldUtils.writeDeclaredField(publicChild, "i", new Integer(1), true);
|
||||
FieldUtils.writeDeclaredField(publicChild, "i", Integer.valueOf(1), true);
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// pass
|
||||
|
@ -1118,8 +1118,8 @@ public class FieldUtilsTest {
|
|||
assertEquals("S", FieldUtils.readDeclaredField(publiclyShadowedChild, "s", true));
|
||||
FieldUtils.writeDeclaredField(publiclyShadowedChild, "b", Boolean.FALSE, true);
|
||||
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(publiclyShadowedChild, "b", true));
|
||||
FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", new Integer(0), true);
|
||||
assertEquals(new Integer(0), FieldUtils.readDeclaredField(publiclyShadowedChild, "i", true));
|
||||
FieldUtils.writeDeclaredField(publiclyShadowedChild, "i", Integer.valueOf(0), true);
|
||||
assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(publiclyShadowedChild, "i", true));
|
||||
FieldUtils.writeDeclaredField(publiclyShadowedChild, "d", new Double(0.0), true);
|
||||
assertEquals(new Double(0.0), FieldUtils.readDeclaredField(publiclyShadowedChild, "d", true));
|
||||
|
||||
|
@ -1127,8 +1127,8 @@ public class FieldUtilsTest {
|
|||
assertEquals("S", FieldUtils.readDeclaredField(privatelyShadowedChild, "s", true));
|
||||
FieldUtils.writeDeclaredField(privatelyShadowedChild, "b", Boolean.FALSE, true);
|
||||
assertEquals(Boolean.FALSE, FieldUtils.readDeclaredField(privatelyShadowedChild, "b", true));
|
||||
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", new Integer(0), true);
|
||||
assertEquals(new Integer(0), FieldUtils.readDeclaredField(privatelyShadowedChild, "i", true));
|
||||
FieldUtils.writeDeclaredField(privatelyShadowedChild, "i", Integer.valueOf(0), true);
|
||||
assertEquals(Integer.valueOf(0), FieldUtils.readDeclaredField(privatelyShadowedChild, "i", true));
|
||||
FieldUtils.writeDeclaredField(privatelyShadowedChild, "d", new Double(0.0), true);
|
||||
assertEquals(new Double(0.0), FieldUtils.readDeclaredField(privatelyShadowedChild, "d", true));
|
||||
}
|
||||
|
|
|
@ -374,13 +374,13 @@ public class TypeUtilsTest<B> {
|
|||
Assert.assertTrue(TypeUtils.isAssignable(float.class, double.class));
|
||||
lo = in;
|
||||
Assert.assertTrue(TypeUtils.isAssignable(int.class, long.class));
|
||||
lo = new Integer(0);
|
||||
lo = Integer.valueOf(0);
|
||||
Assert.assertTrue(TypeUtils.isAssignable(Integer.class, long.class));
|
||||
// Long lngW = 1;
|
||||
Assert.assertFalse(TypeUtils.isAssignable(int.class, Long.class));
|
||||
// lngW = new Integer( 0 );
|
||||
// lngW = Integer.valueOf( 0 );
|
||||
Assert.assertFalse(TypeUtils.isAssignable(Integer.class, Long.class));
|
||||
in = new Integer(0);
|
||||
in = Integer.valueOf(0);
|
||||
Assert.assertTrue(TypeUtils.isAssignable(Integer.class, int.class));
|
||||
Integer inte = in;
|
||||
Assert.assertTrue(TypeUtils.isAssignable(int.class, Integer.class));
|
||||
|
@ -395,7 +395,7 @@ public class TypeUtilsTest<B> {
|
|||
Type longComparableType = getClass().getField("longComparable").getGenericType();
|
||||
// longComparable = 1;
|
||||
Assert.assertFalse(TypeUtils.isAssignable(int.class, longComparableType));
|
||||
// longComparable = new Integer( 0 );
|
||||
// longComparable = Integer.valueOf( 0 );
|
||||
Assert.assertFalse(TypeUtils.isAssignable(Integer.class, longComparableType));
|
||||
// int[] ia;
|
||||
// long[] la = ia;
|
||||
|
|
|
@ -139,8 +139,8 @@ public class ExtendedMessageFormatTest extends TestCase {
|
|||
// ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
|
||||
// assertPatterns(null, pattern, emf.toPattern());
|
||||
// try {
|
||||
// assertEquals("one", emf.format(new Object[] {new Integer(1), "ONE"}));
|
||||
// assertEquals("TWO", emf.format(new Object[] {new Integer(2), "two"}));
|
||||
// assertEquals("one", emf.format(new Object[] {Integer.valueOf(1), "ONE"}));
|
||||
// assertEquals("TWO", emf.format(new Object[] {Integer.valueOf(2), "two"}));
|
||||
// } catch (IllegalArgumentException e) {
|
||||
// // currently sub-formats not supported
|
||||
// }
|
||||
|
@ -153,8 +153,8 @@ public class ExtendedMessageFormatTest extends TestCase {
|
|||
// */
|
||||
// public void testExtendedAndBuiltInWithChoiceFormat() {
|
||||
// String pattern = "Choice: {0,choice,1.0#{0} {1,lower} {2,number}|2.0#{0} {1,upper} {2,number,currency}}";
|
||||
// Object[] lowArgs = new Object[] {new Integer(1), "Low", new Double("1234.56")};
|
||||
// Object[] highArgs = new Object[] {new Integer(2), "High", new Double("9876.54")};
|
||||
// Object[] lowArgs = new Object[] {Integer.valueOf(1), "Low", new Double("1234.56")};
|
||||
// Object[] highArgs = new Object[] {Integer.valueOf(2), "High", new Double("9876.54")};
|
||||
// Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
|
||||
// Locale[] testLocales = new Locale[availableLocales.length + 1];
|
||||
// testLocales[0] = null;
|
||||
|
@ -188,7 +188,7 @@ public class ExtendedMessageFormatTest extends TestCase {
|
|||
* Test the built in choice format.
|
||||
*/
|
||||
public void testBuiltInChoiceFormat() {
|
||||
Object[] values = new Number[] {new Integer(1), new Double("2.2"), new Double("1234.5")};
|
||||
Object[] values = new Number[] {Integer.valueOf(1), new Double("2.2"), new Double("1234.5")};
|
||||
String choicePattern = null;
|
||||
Locale[] availableLocales = ChoiceFormat.getAvailableLocales();
|
||||
|
||||
|
|
|
@ -462,7 +462,7 @@ public class StrBuilderAppendInsertTest extends TestCase {
|
|||
sb.appendln(FOO);
|
||||
assertEquals(SEP + "foo" + SEP, sb.toString());
|
||||
|
||||
sb.appendln(new Integer(6));
|
||||
sb.appendln(Integer.valueOf(6));
|
||||
assertEquals(SEP + "foo" + SEP + "6" + SEP, sb.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -1704,7 +1704,7 @@ public class StrBuilderTest extends TestCase {
|
|||
assertEquals(true, sb1.equals(sb2));
|
||||
assertEquals(true, sb1.equals((Object) sb2));
|
||||
|
||||
assertEquals(false, sb1.equals(new Integer(1)));
|
||||
assertEquals(false, sb1.equals(Integer.valueOf(1)));
|
||||
assertEquals(false, sb1.equals("abc"));
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class StrLookupTest extends TestCase {
|
|||
public void testMapLookup() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("key", "value");
|
||||
map.put("number", new Integer(2));
|
||||
map.put("number", Integer.valueOf(2));
|
||||
assertEquals("value", StrLookup.mapLookup(map).lookup("key"));
|
||||
assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
|
||||
assertEquals(null, StrLookup.mapLookup(map).lookup(null));
|
||||
|
|
|
@ -375,7 +375,7 @@ public class DurationFormatUtilsTest extends TestCase {
|
|||
new Object())));
|
||||
assertFalse("Token equal to Token with different count. ", token.equals(new DurationFormatUtils.Token(
|
||||
DurationFormatUtils.y, 1)));
|
||||
DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(new Integer(1), 4);
|
||||
DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(Integer.valueOf(1), 4);
|
||||
assertTrue("Token with Number value not equal to itself. ", numToken.equals(numToken));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue