Make use of Java 5 auto boxing
Reviewed and replaced when possible: - new Integer - intValue() - new Boolean - booleanValue() - Boolean.TRUE - Boolean.FALSE - new Long - longValue() Issues: SWF-1532
This commit is contained in:
@@ -11,7 +11,7 @@ public class MapAccessorTests extends TestCase {
|
||||
protected void setUp() throws Exception {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("string", "hello");
|
||||
map.put("integer", new Integer(9));
|
||||
map.put("integer", 9);
|
||||
map.put("null", null);
|
||||
this.accessor = new MapAccessor<String, Object>(map);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
}
|
||||
service.addConverter(customConverter);
|
||||
executor = (StaticConversionExecutor) service.getConversionExecutor(String.class, Boolean.class);
|
||||
assertTrue(((Boolean) executor.execute("ja")).booleanValue());
|
||||
assertTrue(((Boolean) executor.execute("ja")));
|
||||
}
|
||||
|
||||
public void testTargetClassNotSupported() {
|
||||
@@ -83,10 +83,10 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
ConversionExecutor executor = service.getConversionExecutor(String.class, Integer.class);
|
||||
Integer three = (Integer) executor.execute("3");
|
||||
assertEquals(3, three.intValue());
|
||||
assertEquals(new Integer(3), three);
|
||||
|
||||
ConversionExecutor executor2 = service.getConversionExecutor(Integer.class, String.class);
|
||||
String threeString = (String) executor2.execute(new Integer(3));
|
||||
String threeString = (String) executor2.execute(3);
|
||||
assertEquals("3", threeString);
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
service.addConverter(converter);
|
||||
ConversionExecutor executor = service.getConversionExecutor(String.class, Integer.class);
|
||||
Integer three = (Integer) executor.execute("3,000");
|
||||
assertEquals(3000, three.intValue());
|
||||
assertEquals(new Integer(3000), three);
|
||||
ConversionExecutor executor2 = service.getConversionExecutor(Integer.class, String.class);
|
||||
String string = (String) executor2.execute(new Integer(3000));
|
||||
String string = (String) executor2.execute(3000);
|
||||
assertEquals("3,000", string);
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
service.addConverter("usaNumber", converter);
|
||||
ConversionExecutor executor = service.getConversionExecutor("usaNumber", String.class, Integer.class);
|
||||
Integer three = (Integer) executor.execute("3,000");
|
||||
assertEquals(3000, three.intValue());
|
||||
assertEquals(new Integer(3000), three);
|
||||
ConversionExecutor executor2 = service.getConversionExecutor("usaNumber", Integer.class, String.class);
|
||||
String string = (String) executor2.execute(new Integer(3000));
|
||||
String string = (String) executor2.execute(3000);
|
||||
assertEquals("3,000", string);
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", Integer.class, List.class);
|
||||
try {
|
||||
executor.execute(new Integer(1));
|
||||
executor.execute(1);
|
||||
fail("Should have failed");
|
||||
} catch (ConversionExecutionException e) {
|
||||
|
||||
@@ -423,7 +423,7 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
ConversionExecutor executor = service.getConversionExecutor(String.class, int.class);
|
||||
Integer three = (Integer) executor.execute("3");
|
||||
assertEquals(3, three.intValue());
|
||||
assertEquals(new Integer(3), three);
|
||||
}
|
||||
|
||||
public void testArrayToArrayConversion() {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class BeanWrapperExpressionParserTests extends TestCase {
|
||||
Expression e = parser.parseExpression(exp, null);
|
||||
assertNotNull(e);
|
||||
Boolean b = (Boolean) e.getValue(bean);
|
||||
assertFalse(b.booleanValue());
|
||||
assertFalse(b);
|
||||
}
|
||||
|
||||
public void testParseSimpleAllowDelimited() {
|
||||
@@ -46,7 +46,7 @@ public class BeanWrapperExpressionParserTests extends TestCase {
|
||||
Expression e = parser.parseExpression(exp, null);
|
||||
assertNotNull(e);
|
||||
Boolean b = (Boolean) e.getValue(bean);
|
||||
assertFalse(b.booleanValue());
|
||||
assertFalse(b);
|
||||
}
|
||||
|
||||
public void testParseSimpleDelimitedNotAllowed() {
|
||||
|
||||
@@ -176,7 +176,7 @@ public class ELExpressionParserTests extends TestCase {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
TestBean context = new TestBean();
|
||||
exp.setValue(context, new Integer(5));
|
||||
exp.setValue(context, 5);
|
||||
assertEquals(5, context.getMaximum());
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class OgnlExpressionParserTests extends TestCase {
|
||||
Expression e = parser.parseExpression(exp, null);
|
||||
assertNotNull(e);
|
||||
Boolean b = (Boolean) e.getValue(bean);
|
||||
assertFalse(b.booleanValue());
|
||||
assertFalse(b);
|
||||
}
|
||||
|
||||
public void testParseSimpleAllowDelimited() {
|
||||
@@ -46,7 +46,7 @@ public class OgnlExpressionParserTests extends TestCase {
|
||||
Expression e = parser.parseExpression(exp, null);
|
||||
assertNotNull(e);
|
||||
Boolean b = (Boolean) e.getValue(bean);
|
||||
assertFalse(b.booleanValue());
|
||||
assertFalse(b);
|
||||
}
|
||||
|
||||
public void testParseSimpleDelimitedNotAllowed() {
|
||||
@@ -141,7 +141,7 @@ public class OgnlExpressionParserTests extends TestCase {
|
||||
public void testVariables() {
|
||||
Expression exp = parser.parseExpression("#var",
|
||||
new FluentParserContext().variable(new ExpressionVariable("var", "flag")));
|
||||
assertEquals(false, ((Boolean) exp.getValue(bean)).booleanValue());
|
||||
assertFalse((Boolean) exp.getValue(bean));
|
||||
}
|
||||
|
||||
public void testVariablesWithCoersion() {
|
||||
@@ -198,7 +198,7 @@ public class OgnlExpressionParserTests extends TestCase {
|
||||
String expressionString = "number";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
TestBean context = new TestBean();
|
||||
exp.setValue(context, new Integer(5));
|
||||
exp.setValue(context, 5);
|
||||
assertEquals(5, context.getNumber());
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
|
||||
public void testParseSimpleEvalExpressionNoParserContext() {
|
||||
String expressionString = "3 + 4";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
assertEquals(new Integer(7), exp.getValue(null)); // Unified EL returns Long
|
||||
assertEquals(7, exp.getValue(null)); // Unified EL returns Long
|
||||
}
|
||||
|
||||
public void testParseNullExpressionString() {
|
||||
@@ -174,7 +174,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
TestBean context = new TestBean();
|
||||
exp.setValue(context, new Integer(5));
|
||||
exp.setValue(context, 5);
|
||||
assertEquals(5, context.getMaximum());
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MethodInvokerTests extends TestCase {
|
||||
|
||||
public void testPrimitiveArg() {
|
||||
Parameters parameters = new Parameters();
|
||||
parameters.add(new Parameter(Boolean.class, new StaticExpression(Boolean.TRUE)));
|
||||
parameters.add(new Parameter(Boolean.class, new StaticExpression(true)));
|
||||
MethodSignature method = new MethodSignature("testPrimitiveArg", parameters);
|
||||
assertEquals(Boolean.TRUE, methodInvoker.invoke(method, new TestObject(), null));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user