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:
Phillip Webb
2012-04-05 14:07:58 -07:00
parent d3ff99c239
commit 22b018e95a
54 changed files with 132 additions and 140 deletions

View File

@@ -50,13 +50,13 @@ public class StringToBoolean extends StringToObject {
protected Object toObject(String string, Class<?> targetClass) throws Exception {
if (trueString != null && string.equals(trueString)) {
return Boolean.TRUE;
return true;
} else if (falseString != null && string.equals(falseString)) {
return Boolean.FALSE;
return false;
} else if (trueString == null && string.equals(VALUE_TRUE)) {
return Boolean.TRUE;
return true;
} else if (falseString == null && string.equals(VALUE_FALSE)) {
return Boolean.FALSE;
return false;
} else {
throw new IllegalArgumentException("Invalid boolean value [" + string + "]");
}

View File

@@ -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);
}

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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());
}

View File

@@ -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());
}

View File

@@ -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());
}

View File

@@ -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));
}

View File

@@ -76,7 +76,7 @@ public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingle
private boolean parseEnableManagedBeans(Element element, BeanDefinitionBuilder definitionBuilder) {
String enableManagedBeans = element.getAttribute(ENABLE_MANAGED_BEANS_ATTR);
if (StringUtils.hasText(enableManagedBeans)) {
return Boolean.valueOf(enableManagedBeans).booleanValue();
return Boolean.valueOf(enableManagedBeans);
} else {
return false;
}

View File

@@ -41,7 +41,7 @@ public abstract class ELDelegatingPropertyResolver extends PropertyResolver {
public Class<?> getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
ELContext elContext = new SimpleELContext(delegate);
Class<?> type = elContext.getELResolver().getType(elContext, base, new Integer(index));
Class<?> type = elContext.getELResolver().getType(elContext, base, index);
if (elContext.isPropertyResolved()) {
return type;
} else {
@@ -61,7 +61,7 @@ public abstract class ELDelegatingPropertyResolver extends PropertyResolver {
public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException {
ELContext elContext = new SimpleELContext(delegate);
Object value = elContext.getELResolver().getValue(elContext, base, new Integer(index));
Object value = elContext.getELResolver().getValue(elContext, base, index);
if (elContext.isPropertyResolved()) {
return value;
} else {
@@ -81,7 +81,7 @@ public abstract class ELDelegatingPropertyResolver extends PropertyResolver {
public boolean isReadOnly(Object base, int index) throws EvaluationException, PropertyNotFoundException {
ELContext elContext = new SimpleELContext(delegate);
boolean readOnly = elContext.getELResolver().isReadOnly(elContext, base, new Integer(index));
boolean readOnly = elContext.getELResolver().isReadOnly(elContext, base, index);
if (elContext.isPropertyResolved()) {
return readOnly;
} else {
@@ -101,7 +101,7 @@ public abstract class ELDelegatingPropertyResolver extends PropertyResolver {
public void setValue(Object base, int index, Object value) throws EvaluationException, PropertyNotFoundException {
ELContext elContext = new SimpleELContext(delegate);
elContext.getELResolver().setValue(elContext, base, new Integer(index), value);
elContext.getELResolver().setValue(elContext, base, index, value);
if (!elContext.isPropertyResolved()) {
nextResolver.setValue(base, index, value);
}

View File

@@ -42,12 +42,12 @@ public class DojoStyleRenderer extends Renderer {
if (component.getAttributes().containsKey(THEME_PATH_ATTR)) {
themePath = (String) component.getAttributes().get(THEME_PATH_ATTR);
context.getViewRoot().getAttributes().put(DojoConstants.CUSTOM_THEME_PATH_SET, Boolean.TRUE);
context.getViewRoot().getAttributes().put(DojoConstants.CUSTOM_THEME_PATH_SET, true);
}
if (component.getAttributes().containsKey(THEME_ATTR)) {
theme = (String) component.getAttributes().get(THEME_ATTR);
context.getViewRoot().getAttributes().put(DojoConstants.CUSTOM_THEME_SET, Boolean.TRUE);
context.getViewRoot().getAttributes().put(DojoConstants.CUSTOM_THEME_SET, true);
}
ResourceHelper.renderStyleLink(context, themePath + theme + "/" + theme + ".css");

View File

@@ -123,7 +123,7 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend
button.getAttributes().putAll(component.getAttributes());
BeanUtils.copyProperties(component, button);
button.setRendererType("spring.faces.ProgressiveCommandButtonRenderer");
button.setAjaxEnabled(Boolean.FALSE);
button.setAjaxEnabled(false);
button.encodeBegin(context);
button.encodeChildren(context);
button.encodeEnd(context);

View File

@@ -38,7 +38,7 @@ public class ProgressiveUICommand extends UICommand {
private Boolean disabled;
private Boolean ajaxEnabled = Boolean.TRUE;
private Boolean ajaxEnabled = true;
public String getType() {
return type;
@@ -53,7 +53,7 @@ public class ProgressiveUICommand extends UICommand {
return disabled;
}
ValueBinding vb = getValueBinding("disabled");
return vb != null ? (Boolean) vb.getValue(getFacesContext()) : Boolean.FALSE;
return vb != null ? (Boolean) vb.getValue(getFacesContext()) : false;
}
public void setDisabled(Boolean disabled) {

View File

@@ -148,7 +148,7 @@ public class FlowActionListener implements ActionListener {
TransitionDefinition transition = requestContext.getMatchingTransition(eventId);
if (transition != null) {
if (transition.getAttributes().contains("validate")) {
return transition.getAttributes().getBoolean("validate").booleanValue();
return transition.getAttributes().getBoolean("validate");
}
}
return true;

View File

@@ -148,10 +148,7 @@ public class FlowFacesContext extends FacesContext {
public boolean getRenderResponse() {
Boolean renderResponse = context.getFlashScope().getBoolean(RENDER_RESPONSE_KEY);
if (renderResponse == null) {
return false;
}
return renderResponse.booleanValue();
return (renderResponse == null ? false : renderResponse);
}
public boolean getResponseComplete() {
@@ -160,7 +157,7 @@ public class FlowFacesContext extends FacesContext {
public void renderResponse() {
// stored in flash scope to survive a redirect when transitioning from one view to another
context.getFlashScope().put(RENDER_RESPONSE_KEY, Boolean.TRUE);
context.getFlashScope().put(RENDER_RESPONSE_KEY, true);
}
public void responseComplete() {

View File

@@ -98,7 +98,7 @@ public class SelectionTrackingActionListenerTests extends TestCase {
int.class });
indexMutator.setAccessible(true);
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new Object[] { new MockFacesContext(), new Integer(1) });
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new Object[] { new MockFacesContext(), 1 });
ActionEvent event = new ActionEvent(commandButton);
@@ -108,7 +108,7 @@ public class SelectionTrackingActionListenerTests extends TestCase {
assertSame(dataModel.getSelectedRow(), dataModel.getRowData());
assertTrue(delegateListener.processedEvent);
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new Object[] { new MockFacesContext(), new Integer(2) });
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new Object[] { new MockFacesContext(), 2 });
assertFalse(dataModel.isCurrentRowSelected());
assertTrue(dataModel.getSelectedRow() != dataModel.getRowData());
}

View File

@@ -79,7 +79,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase {
form.setId("myForm");
ProgressiveUICommand link = new ProgressiveUICommand();
link.setId("foo");
link.setAjaxEnabled(Boolean.FALSE);
link.setAjaxEnabled(false);
form.getChildren().add(link);
RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick");
@@ -102,7 +102,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase {
form.setId("myForm");
ProgressiveUICommand link = new ProgressiveUICommand();
link.setId("foo");
link.setAjaxEnabled(Boolean.FALSE);
link.setAjaxEnabled(false);
form.getChildren().add(link);
UIParameter param1 = new UIParameter();
param1.setName("foo");

View File

@@ -87,7 +87,7 @@ public class JsfFinalResponseActionTests extends TestCase {
newRoot.setRenderKitId("HTML_BASIC");
((MockViewHandler) viewHandler).setCreateView(newRoot);
context.inViewState();
EasyMock.expectLastCall().andReturn(Boolean.FALSE);
EasyMock.expectLastCall().andReturn(false);
EasyMock.replay(new Object[] { context });

View File

@@ -112,7 +112,7 @@ public class JsfViewFactoryTests extends TestCase {
newRoot.setViewId(VIEW_ID);
((MockViewHandler) viewHandler).setCreateView(newRoot);
context.inViewState();
EasyMock.expectLastCall().andReturn(Boolean.TRUE);
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { context });
@@ -143,7 +143,7 @@ public class JsfViewFactoryTests extends TestCase {
((MockViewHandler) viewHandler).setRestoreView(existingRoot);
context.inViewState();
EasyMock.expectLastCall().andReturn(Boolean.TRUE);
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { context });
@@ -189,7 +189,7 @@ public class JsfViewFactoryTests extends TestCase {
((MockViewHandler) viewHandler).setRestoreView(existingRoot);
context.inViewState();
EasyMock.expectLastCall().andReturn(Boolean.TRUE);
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { context });
@@ -224,7 +224,7 @@ public class JsfViewFactoryTests extends TestCase {
EasyMock.expect(context.getCurrentState()).andReturn(new NormalViewState());
context.inViewState();
EasyMock.expectLastCall().andReturn(Boolean.TRUE);
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { context });
@@ -276,7 +276,7 @@ public class JsfViewFactoryTests extends TestCase {
((MockViewHandler) viewHandler).setRestoreView(existingRoot);
context.inViewState();
EasyMock.expectLastCall().andReturn(Boolean.TRUE);
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { context });
factory.getView(context);

View File

@@ -139,7 +139,7 @@ public class JsfViewTests extends TestCase {
public final void testProcessUserEvent_Restored_NoEvent() {
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn(
Boolean.FALSE);
false);
EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
.andStubReturn(null);
@@ -165,7 +165,7 @@ public class JsfViewTests extends TestCase {
public final void testProcessUserEvent_Restored_Ajax_NoEvent() {
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn(
Boolean.FALSE);
false);
EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
.andStubReturn(null);
@@ -191,7 +191,7 @@ public class JsfViewTests extends TestCase {
public final void testProcessUserEvent_Restored_EventSignaled() {
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn(
Boolean.FALSE);
false);
EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
.andStubReturn(null);

View File

@@ -73,7 +73,7 @@ public class ResultObjectBasedEventFactory extends EventFactorySupport implement
// by this class but the value is null
return event(source, getNullEventId());
} else if (isBoolean(resultObject.getClass())) {
return event(source, ((Boolean) resultObject).booleanValue());
return event(source, ((Boolean) resultObject));
} else if (isLabeledEnum(resultObject.getClass())) {
String resultId = ((LabeledEnum) resultObject).getLabel();
return event(source, resultId, getResultAttributeName(), resultObject);

View File

@@ -97,14 +97,14 @@ class FlowExecutorFactoryBean implements FactoryBean<FlowExecutor>, ApplicationC
* Set the maximum number of allowed flow executions allowed per user.
*/
public void setMaxFlowExecutions(int maxFlowExecutions) {
this.maxFlowExecutions = new Integer(maxFlowExecutions);
this.maxFlowExecutions = maxFlowExecutions;
}
/**
* Set the maximum number of history snapshots allowed per flow execution.
*/
public void setMaxFlowExecutionSnapshots(int maxFlowExecutionSnapshots) {
this.maxFlowExecutionSnapshots = new Integer(maxFlowExecutionSnapshots);
this.maxFlowExecutionSnapshots = maxFlowExecutionSnapshots;
}
/**
@@ -186,11 +186,11 @@ class FlowExecutorFactoryBean implements FactoryBean<FlowExecutor>, ApplicationC
private void putDefaultFlowExecutionAttributes(LocalAttributeMap<Object> executionAttributes) {
if (!executionAttributes.contains(ALWAYS_REDIRECT_ON_PAUSE)) {
Boolean redirect = (environment == MvcEnvironment.PORTLET) ? Boolean.FALSE : Boolean.TRUE;
Boolean redirect = (environment != MvcEnvironment.PORTLET);
executionAttributes.put(ALWAYS_REDIRECT_ON_PAUSE, redirect);
}
if (!executionAttributes.contains(REDIRECT_IN_SAME_STATE)) {
Boolean redirect = (environment == MvcEnvironment.PORTLET) ? Boolean.FALSE : Boolean.TRUE;
Boolean redirect = (environment != MvcEnvironment.PORTLET);
executionAttributes.put(REDIRECT_IN_SAME_STATE, redirect);
}
}
@@ -200,7 +200,7 @@ class FlowExecutorFactoryBean implements FactoryBean<FlowExecutor>, ApplicationC
FlowExecutionSnapshotFactory snapshotFactory = createFlowExecutionSnapshotFactory(executionFactory);
DefaultFlowExecutionRepository rep = new DefaultFlowExecutionRepository(conversationManager, snapshotFactory);
if (maxFlowExecutionSnapshots != null) {
rep.setMaxSnapshots(maxFlowExecutionSnapshots.intValue());
rep.setMaxSnapshots(maxFlowExecutionSnapshots);
}
return rep;
}
@@ -209,16 +209,15 @@ class FlowExecutorFactoryBean implements FactoryBean<FlowExecutor>, ApplicationC
if (conversationManager == null) {
conversationManager = new SessionBindingConversationManager();
if (maxFlowExecutions != null) {
((SessionBindingConversationManager) conversationManager).setMaxConversations(maxFlowExecutions
.intValue());
((SessionBindingConversationManager) conversationManager).setMaxConversations(maxFlowExecutions);
}
}
return this.conversationManager;
}
private FlowExecutionSnapshotFactory createFlowExecutionSnapshotFactory(FlowExecutionFactory executionFactory) {
if (maxFlowExecutionSnapshots != null && maxFlowExecutionSnapshots.intValue() == 0) {
maxFlowExecutionSnapshots = new Integer(1);
if (maxFlowExecutionSnapshots != null && maxFlowExecutionSnapshots == 0) {
maxFlowExecutionSnapshots = 1;
return new SimpleFlowExecutionSnapshotFactory(executionFactory, flowDefinitionLocator);
} else {
return new SerializedFlowExecutionSnapshotFactory(executionFactory, flowDefinitionLocator);
@@ -259,4 +258,4 @@ class FlowExecutorFactoryBean implements FactoryBean<FlowExecutor>, ApplicationC
}
}
}
}

View File

@@ -214,7 +214,7 @@ class FlowRegistryFactoryBean implements FactoryBean<FlowDefinitionRegistry>, Be
MutableAttributeMap<Object> flowAttributes = null;
if (flowBuilderServices.getDevelopment()) {
flowAttributes = new LocalAttributeMap<Object>(1 + attributes.size(), 1);
flowAttributes.put("development", Boolean.TRUE);
flowAttributes.put("development", true);
}
if (!attributes.isEmpty()) {
if (flowAttributes == null) {

View File

@@ -238,7 +238,7 @@ public class Flow extends AnnotatedObject implements FlowDefinition {
}
public boolean inDevelopment() {
return getAttributes().getBoolean("development", Boolean.FALSE).booleanValue();
return getAttributes().getBoolean("development", false);
}
/**
@@ -663,4 +663,4 @@ public class Flow extends AnnotatedObject implements FlowDefinition {
.append("outputMapper", outputMapper).toString();
}
}
}

View File

@@ -122,7 +122,7 @@ public class ViewState extends TransitionableState {
* Returns whether this view state should request a flow execution redirect when entered.
*/
public boolean getRedirect() {
return (redirect != null) ? redirect.booleanValue() : false;
return (redirect == null) ? false : redirect;
}
/**
@@ -266,7 +266,7 @@ public class ViewState extends TransitionableState {
private boolean shouldRedirect(RequestControlContext context) {
if (redirect != null) {
return redirect.booleanValue();
return redirect;
}
if (context.getExternalContext().isAjaxRequest() && context.getEmbeddedMode()) {
return false;
@@ -276,7 +276,7 @@ public class ViewState extends TransitionableState {
private boolean shouldRedirectInSameState(RequestControlContext context) {
if (redirect != null) {
return redirect.booleanValue();
return redirect;
}
if (context.getExternalContext().isAjaxRequest() && context.getEmbeddedMode()) {
return false;

View File

@@ -346,7 +346,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
}
private boolean isFlowInDevelopment() {
return getContext().getFlowAttributes().getBoolean("development", Boolean.FALSE).booleanValue();
return getContext().getFlowAttributes().getBoolean("development", false);
}
private void registerMessageSource(GenericApplicationContext flowContext, Resource flowResource) {
@@ -513,8 +513,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
private void parseAndSetMappingRequired(AbstractMappingModel mappingModel, DefaultMapping mapping) {
if (StringUtils.hasText(mappingModel.getRequired())) {
boolean required = ((Boolean) fromStringTo(Boolean.class).execute(mappingModel.getRequired()))
.booleanValue();
boolean required = ((Boolean) fromStringTo(Boolean.class).execute(mappingModel.getRequired()));
mapping.setRequired(required);
}
}
@@ -527,7 +526,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
}
boolean popup = false;
if (StringUtils.hasText(state.getPopup())) {
popup = ((Boolean) fromStringTo(Boolean.class).execute(state.getPopup())).booleanValue();
popup = ((Boolean) fromStringTo(Boolean.class).execute(state.getPopup()));
}
MutableAttributeMap<Object> attributes = parseMetaAttributes(state.getAttributes());
if (state.getModel() != null) {
@@ -631,12 +630,9 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
BinderConfiguration binderConfiguration = new BinderConfiguration();
List<BindingModel> bindings = binderModel.getBindings();
for (BindingModel bindingModel : bindings) {
boolean required;
boolean required = false;
if (StringUtils.hasText(bindingModel.getRequired())) {
required = ((Boolean) fromStringTo(Boolean.class).execute(bindingModel.getRequired()))
.booleanValue();
} else {
required = false;
required = ((Boolean) fromStringTo(Boolean.class).execute(bindingModel.getRequired()));
}
Binding binding = new Binding(bindingModel.getProperty(), bindingModel.getConverter(), required);
binderConfiguration.addBinding(binding);
@@ -915,7 +911,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
private void parseAndPutPersistenceContext(PersistenceContextModel persistenceContext,
MutableAttributeMap<Object> attributes) {
if (persistenceContext != null) {
attributes.put("persistenceContext", Boolean.TRUE);
attributes.put("persistenceContext", true);
}
}

View File

@@ -123,7 +123,7 @@ class FlowSessionImpl implements FlowSession, Externalizable {
}
public boolean isEmbeddedMode() {
return (Boolean) scope.get(EMBEDDED_MODE_ATTRIBUTE, Boolean.FALSE);
return (Boolean) scope.get(EMBEDDED_MODE_ATTRIBUTE, false);
}
public FlowSession getParent() {

View File

@@ -243,7 +243,7 @@ class RequestControlContextImpl implements RequestControlContext {
return true;
}
Boolean redirectOnPause = flowExecution.getAttributes().getBoolean("alwaysRedirectOnPause");
return redirectOnPause != null ? redirectOnPause.booleanValue() : false;
return redirectOnPause == null ? false : redirectOnPause;
}
public boolean getRedirectInSameState() {
@@ -251,7 +251,7 @@ class RequestControlContextImpl implements RequestControlContext {
return true;
}
Boolean redirectInSameState = flowExecution.getAttributes().getBoolean("redirectInSameState");
return (redirectInSameState != null) ? redirectInSameState.booleanValue() : getRedirectOnPause();
return (redirectInSameState != null) ? redirectInSameState : getRedirectOnPause();
}
public boolean getEmbeddedMode() {

View File

@@ -49,7 +49,7 @@ public class DefaultTransitionCriteria implements TransitionCriteria {
if (result == null) {
return false;
} else if (result instanceof Boolean) {
return ((Boolean) result).booleanValue();
return (Boolean) result;
} else {
String eventId = String.valueOf(result);
return context.getCurrentEvent().getId().equals(eventId);

View File

@@ -303,7 +303,7 @@ public abstract class AbstractMvcView implements View {
if (transition == null) {
return true;
}
return transition.getAttributes().getBoolean("bind", Boolean.TRUE).booleanValue();
return transition.getAttributes().getBoolean("bind", true);
}
/**
@@ -523,12 +523,12 @@ public abstract class AbstractMvcView implements View {
protected boolean shouldValidate(Object model, TransitionDefinition transition) {
Boolean validateAttribute = getValidateAttribute(transition);
if (validateAttribute != null) {
return validateAttribute.booleanValue();
return validateAttribute;
} else {
AttributeMap<Object> flowExecutionAttributes = requestContext.getFlowExecutionContext().getAttributes();
Boolean validateOnBindingErrors = flowExecutionAttributes.getBoolean("validateOnBindingErrors");
if (validateOnBindingErrors != null) {
if (!validateOnBindingErrors.booleanValue() && mappingResults.hasErrorResults()) {
if (!validateOnBindingErrors && mappingResults.hasErrorResults()) {
return false;
}
}
@@ -580,7 +580,7 @@ public abstract class AbstractMvcView implements View {
private Object getEmptyValue(Class<?> fieldType) {
if (fieldType != null && boolean.class.equals(fieldType) || Boolean.class.equals(fieldType)) {
// Special handling of boolean property.
return Boolean.FALSE;
return false;
} else if (fieldType != null && fieldType.isArray()) {
// Special handling of array property.
return Array.newInstance(fieldType.getComponentType(), 0);

View File

@@ -157,7 +157,7 @@ public class MockExternalContext implements ExternalContext {
public boolean isResponseAllowed() {
if (responseAllowed != null) {
return responseAllowed.booleanValue();
return responseAllowed;
} else {
return !responseComplete;
}

View File

@@ -106,7 +106,7 @@ public class MockFlowSession implements FlowSession {
}
public boolean isEmbeddedMode() {
return (Boolean) scope.get(EMBEDDED_MODE_ATTRIBUTE, Boolean.FALSE);
return (Boolean) scope.get(EMBEDDED_MODE_ATTRIBUTE, false);
}
public FlowSession getParent() {

View File

@@ -122,7 +122,7 @@ public class MockRequestControlContext extends MockRequestContext implements Req
return true;
}
Boolean redirectOnPause = getMockFlowExecutionContext().getAttributes().getBoolean("alwaysRedirectOnPause");
return redirectOnPause != null ? redirectOnPause.booleanValue() : false;
return redirectOnPause == null ? false : redirectOnPause;
}
public boolean getRedirectInSameState() {
@@ -131,7 +131,7 @@ public class MockRequestControlContext extends MockRequestContext implements Req
}
Boolean redirectInSameState = getMockFlowExecutionContext().getAttributes().getBoolean("redirectInSameState");
if (redirectInSameState != null) {
return redirectInSameState.booleanValue();
return redirectInSameState;
} else {
return getRedirectOnPause();
}

View File

@@ -76,7 +76,7 @@ public class FormActionBindingTests extends TestCase {
FormAction formAction = new FormAction() {
protected Object createFormObject(RequestContext context) throws Exception {
TestBean res = new TestBean();
res.setProp(new Long(-1));
res.setProp(-1L);
res.otherProp = "initialValue";
return res;
}

View File

@@ -37,9 +37,9 @@ public class ResultObjectBasedEventFactoryTests extends TestCase {
}
public void testBoolean() {
Event event = factory.createResultEvent(this, Boolean.TRUE, new MockRequestContext());
Event event = factory.createResultEvent(this, true, new MockRequestContext());
assertEquals(factory.getYesEventId(), event.getId());
event = factory.createResultEvent(this, Boolean.FALSE, new MockRequestContext());
event = factory.createResultEvent(this, false, new MockRequestContext());
assertEquals(factory.getNoEventId(), event.getId());
}

View File

@@ -49,9 +49,9 @@ public class ResultObjectEventFactoryTests extends TestCase {
}
public void testBooleanResult() {
Event result = factory.createResultEvent(this, Boolean.TRUE, context);
Event result = factory.createResultEvent(this, true, context);
assertEquals("yes", result.getId());
result = factory.createResultEvent(this, Boolean.FALSE, context);
result = factory.createResultEvent(this, false, context);
assertEquals("no", result.getId());
}

View File

@@ -85,7 +85,7 @@ public class DefaultFlowUrlHandlerTests extends TestCase {
LocalAttributeMap<Object> input = new LocalAttributeMap<Object>(new LinkedHashMap<String, Object>());
input.put("foo", "bar");
input.put("bar", "needs encoding");
input.put("baz", new Integer(1));
input.put("baz", 1);
input.put("boop", null);
String url = urlHandler.createFlowDefinitionUrl("bookHotel", input, request);
assertEquals("/springtravel/app/bookHotel?foo=bar&bar=needs+encoding&baz=1&boop=", url);

View File

@@ -39,7 +39,7 @@ public class WebFlow1FlowUrlHandlerTests extends TestCase {
LocalAttributeMap<Object> input = new LocalAttributeMap<Object>(new LinkedHashMap<String, Object>());
input.put("foo", "bar");
input.put("bar", "needs encoding");
input.put("baz", new Integer(1));
input.put("baz", 1);
input.put("boop", null);
String url = urlHandler.createFlowDefinitionUrl("bookHotel", input, request);
assertEquals("/springtravel/app/flows?_flowId=bookHotel&foo=bar&bar=needs+encoding&baz=1&boop=", url);

View File

@@ -31,9 +31,9 @@ public class LocalAttributeMapTests extends TestCase {
public void setUp() {
attributeMap.put("string", "A string");
attributeMap.put("integer", new Integer(12345));
attributeMap.put("boolean", Boolean.TRUE);
attributeMap.put("long", new Long(12345));
attributeMap.put("integer", 12345);
attributeMap.put("boolean", true);
attributeMap.put("long", 12345L);
attributeMap.put("double", new Double(12345));
attributeMap.put("float", new Float(12345));
attributeMap.put("bigDecimal", new BigDecimal("12345.67"));
@@ -333,4 +333,4 @@ public class LocalAttributeMapTests extends TestCase {
assertFalse(attributeMap.contains("string"));
}
}
}

View File

@@ -85,7 +85,7 @@ public class LocalParameterMapTests extends TestCase {
}
public void testGetWithDefaultAndConversion() {
Object value = parameterMap.get("bogus", Integer.class, new Integer(1));
Object value = parameterMap.get("bogus", Integer.class, 1);
assertEquals(new Integer(1), value);
}
@@ -226,7 +226,7 @@ public class LocalParameterMapTests extends TestCase {
}
public void testGetBooleanWithDefault() {
Boolean value = parameterMap.getBoolean("bogus", Boolean.TRUE);
Boolean value = parameterMap.getBoolean("bogus", true);
assertEquals(Boolean.TRUE, value);
}
@@ -249,4 +249,4 @@ public class LocalParameterMapTests extends TestCase {
AttributeMap<Object> map = parameterMap.asAttributeMap();
assertEquals(map.asMap(), parameterMap.asMap());
}
}
}

View File

@@ -62,7 +62,7 @@ public class FlowExecutionHandlerSetTests extends TestCase {
}
public void handle(FlowExecutionException exception, RequestControlContext context) {
context.getFlowScope().put(resultName, Boolean.TRUE);
context.getFlowScope().put(resultName, true);
}
}

View File

@@ -301,7 +301,7 @@ public class FlowTests extends TestCase {
MockRequestControlContext context = new MockRequestControlContext(flow);
context.setCurrentState(flow.getStateInstance("myState1"));
flow.resume(context);
assertTrue(context.getFlowScope().getBoolean("renderCalled").booleanValue());
assertTrue(context.getFlowScope().getBoolean("renderCalled"));
}
public void testEnd() {

View File

@@ -39,7 +39,7 @@ public class StubViewFactory implements ViewFactory {
}
public void render() {
context.getFlowScope().put("renderCalled", Boolean.TRUE);
context.getFlowScope().put("renderCalled", true);
}
public boolean userEventQueued() {
@@ -63,7 +63,7 @@ public class StubViewFactory implements ViewFactory {
}
public void saveState() {
context.getFlowScope().put("saveStateCalled", Boolean.TRUE);
context.getFlowScope().put("saveStateCalled", true);
}
}

View File

@@ -110,7 +110,7 @@ public class ViewStateTests extends TestCase {
Flow flow = new Flow("myFlow");
StubViewFactory viewFactory = new StubViewFactory();
ViewState state = new ViewState(flow, "viewState", viewFactory);
state.setRedirect(Boolean.TRUE);
state.setRedirect(true);
MockRequestControlContext context = new MockRequestControlContext(flow);
context.getFlashScope().put("foo", "bar");
state.enter(context);
@@ -123,7 +123,7 @@ public class ViewStateTests extends TestCase {
Flow flow = new Flow("myFlow");
StubViewFactory viewFactory = new StubViewFactory();
ViewState state = new ViewState(flow, "viewState", viewFactory);
state.setRedirect(Boolean.FALSE);
state.setRedirect(false);
MockRequestControlContext context = new MockRequestControlContext(flow);
context.getFlashScope().put("foo", "bar");
state.enter(context);
@@ -136,7 +136,7 @@ public class ViewStateTests extends TestCase {
Flow flow = new Flow("myFlow");
StubViewFactory viewFactory = new StubViewFactory();
ViewState state = new ViewState(flow, "viewState", viewFactory);
state.setRedirect(Boolean.TRUE);
state.setRedirect(true);
state.setPopup(true);
MockRequestControlContext context = new MockRequestControlContext(flow);
context.getFlashScope().put("foo", "bar");

View File

@@ -110,7 +110,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
model.setStates(asList(AbstractStateModel.class, new EndStateModel("end")));
Flow flow = getFlow(model);
assertNotNull(flow.getAttributes().get("persistenceContext"));
assertTrue(((Boolean) flow.getAttributes().get("persistenceContext")).booleanValue());
assertTrue((Boolean) flow.getAttributes().get("persistenceContext"));
}
public void testFlowInputOutputMapping() {

View File

@@ -258,7 +258,7 @@ public class DefaultFlowExecutionRepositoryTests extends TestCase {
public ConversationId parseConversationId(String encodedId) throws ConversationException {
try {
return new SimpleConversationId(new Integer(Integer.parseInt(encodedId)));
return new SimpleConversationId(Integer.parseInt(encodedId));
} catch (NumberFormatException e) {
throw new BadlyFormattedConversationIdException(encodedId, e);
}
@@ -266,7 +266,7 @@ public class DefaultFlowExecutionRepositoryTests extends TestCase {
private static class StubConversation implements Conversation {
private final ConversationId ID = new SimpleConversationId(new Integer(12345));
private final ConversationId ID = new SimpleConversationId(12345);
private boolean ended;

View File

@@ -56,7 +56,7 @@ public class SimpleFlowExecutionSnapshotGroupTests extends TestCase {
group.addSnapshot(group.nextSnapshotId(), snapshot3);
assertEquals(2, group.getSnapshotCount());
try {
group.getSnapshot(new Integer(1));
group.getSnapshot(1);
fail("Should have failed");
} catch (SnapshotNotFoundException e) {
@@ -67,10 +67,10 @@ public class SimpleFlowExecutionSnapshotGroupTests extends TestCase {
group.addSnapshot(group.nextSnapshotId(), snapshot);
group.addSnapshot(group.nextSnapshotId(), snapshot2);
assertEquals(2, group.getSnapshotCount());
group.removeSnapshot(new Integer(1));
group.removeSnapshot(1);
assertEquals(1, group.getSnapshotCount());
try {
group.getSnapshot(new Integer(1));
group.getSnapshot(1);
fail("Should have failed");
} catch (SnapshotNotFoundException e) {
@@ -87,15 +87,15 @@ public class SimpleFlowExecutionSnapshotGroupTests extends TestCase {
public void testUpdateSnapshot() {
group.addSnapshot(group.nextSnapshotId(), snapshot);
group.updateSnapshot(new Integer(1), snapshot2);
assertSame(snapshot2, group.getSnapshot(new Integer(1)));
group.updateSnapshot(1, snapshot2);
assertSame(snapshot2, group.getSnapshot(1));
}
public void testRemoveSnapshotDoesNotExist() {
group.addSnapshot(group.nextSnapshotId(), snapshot);
group.removeSnapshot(new Integer(1));
group.removeSnapshot(1);
assertEquals(0, group.getSnapshotCount());
group.removeSnapshot(new Integer(1));
group.removeSnapshot(1);
assertEquals(0, group.getSnapshotCount());
}
@@ -109,7 +109,7 @@ public class SimpleFlowExecutionSnapshotGroupTests extends TestCase {
public void testUpdateSnapshotDoesNotExist() {
assertEquals(0, group.getSnapshotCount());
group.updateSnapshot(new Integer(1), snapshot2);
group.updateSnapshot(1, snapshot2);
assertEquals(0, group.getSnapshotCount());
}

View File

@@ -51,7 +51,7 @@ public class FlowExecutorImplTests extends TestCase {
execution.start(input, context);
execution.hasEnded();
EasyMock.expectLastCall().andReturn(Boolean.FALSE);
EasyMock.expectLastCall().andReturn(false);
MockFlowExecutionKey flowExecutionKey = new MockFlowExecutionKey("12345");
EasyMock.expect(execution.getKey()).andReturn(flowExecutionKey);
@@ -89,7 +89,7 @@ public class FlowExecutorImplTests extends TestCase {
execution.start(input, context);
execution.hasEnded();
EasyMock.expectLastCall().andReturn(Boolean.TRUE);
EasyMock.expectLastCall().andReturn(true);
EasyMock.expect(execution.getDefinition()).andReturn(definition);
EasyMock.expect(definition.getId()).andReturn("foo");
@@ -121,7 +121,7 @@ public class FlowExecutorImplTests extends TestCase {
execution.resume(context);
execution.hasEnded();
EasyMock.expectLastCall().andReturn(Boolean.FALSE);
EasyMock.expectLastCall().andReturn(false);
repository.putFlowExecution(execution);
@@ -158,7 +158,7 @@ public class FlowExecutorImplTests extends TestCase {
execution.resume(context);
execution.hasEnded();
EasyMock.expectLastCall().andReturn(Boolean.TRUE);
EasyMock.expectLastCall().andReturn(true);
EasyMock.expect(execution.getDefinition()).andReturn(definition);
EasyMock.expect(definition.getId()).andReturn("foo");

View File

@@ -67,7 +67,7 @@ public class ServletMvcViewTests extends TestCase {
public static class BindBean {
private String stringProperty;
private Integer integerProperty = new Integer(3);
private Integer integerProperty = 3;
private Date dateProperty;
public BindBean() {

View File

@@ -612,7 +612,7 @@ public class MvcViewTests extends TestCase {
BindBean bindBean = new ValidatingBindBean();
StaticExpression modelObject = new StaticExpression(bindBean);
modelObject.setExpressionString("bindBean");
context.getMockFlowExecutionContext().putAttribute("validateOnBindingErrors", Boolean.FALSE);
context.getMockFlowExecutionContext().putAttribute("validateOnBindingErrors", false);
context.getCurrentState().getAttributes().put("model", modelObject);
context.getFlowScope().put("bindBean", bindBean);
context.getMockExternalContext().setNativeContext(new MockServletContext());
@@ -666,7 +666,7 @@ public class MvcViewTests extends TestCase {
public static class BindBean {
private String stringProperty;
private Integer integerProperty = new Integer(3);
private Integer integerProperty = 3;
private Date dateProperty;
private boolean booleanProperty = true;
private NestedBean beanProperty;

View File

@@ -125,7 +125,7 @@ public abstract class AbstractPersistenceContextPropagationTests extends TestCas
flowSession.getDefinition().getAttributes().put("persistenceContext", "true");
}
EndState endState = new EndState(flowSession.getDefinitionInternal(), "success");
endState.getAttributes().put("commit", Boolean.TRUE);
endState.getAttributes().put("commit", true);
flowSession.setState(endState);
return flowSession;
}

View File

@@ -116,7 +116,7 @@ public class HibernateFlowExecutionListenerTests extends TestCase {
assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
EndState endState = new EndState(flowSession.getDefinitionInternal(), "success");
endState.getAttributes().put("commit", Boolean.TRUE);
endState.getAttributes().put("commit", true);
flowSession.setState(endState);
hibernateListener.sessionEnding(context, flowSession, "success", null);
@@ -147,7 +147,7 @@ public class HibernateFlowExecutionListenerTests extends TestCase {
assertSessionBound();
EndState endState = new EndState(flowSession.getDefinitionInternal(), "success");
endState.getAttributes().put("commit", Boolean.TRUE);
endState.getAttributes().put("commit", true);
flowSession.setState(endState);
hibernateListener.sessionEnding(context, flowSession, "success", null);
@@ -171,7 +171,7 @@ public class HibernateFlowExecutionListenerTests extends TestCase {
assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
EndState endState = new EndState(flowSession.getDefinitionInternal(), "cancel");
endState.getAttributes().put("commit", Boolean.FALSE);
endState.getAttributes().put("commit", false);
flowSession.setState(endState);
hibernateListener.sessionEnding(context, flowSession, "success", null);
hibernateListener.sessionEnded(context, flowSession, "cancel", null);

View File

@@ -66,7 +66,7 @@ public class JpaFlowExecutionListenerTests extends TestCase {
assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
EndState endState = new EndState(flowSession.getDefinitionInternal(), "success");
endState.getAttributes().put("commit", Boolean.TRUE);
endState.getAttributes().put("commit", true);
flowSession.setState(endState);
jpaListener.sessionEnding(context, flowSession, "success", null);
@@ -97,7 +97,7 @@ public class JpaFlowExecutionListenerTests extends TestCase {
assertSessionBound();
EndState endState = new EndState(flowSession.getDefinitionInternal(), "success");
endState.getAttributes().put("commit", Boolean.TRUE);
endState.getAttributes().put("commit", true);
flowSession.setState(endState);
jpaListener.sessionEnding(context, flowSession, "success", null);
@@ -121,7 +121,7 @@ public class JpaFlowExecutionListenerTests extends TestCase {
assertEquals("Table should still only have one row", 1, jdbcTemplate.queryForInt("select count(*) from T_BEAN"));
EndState endState = new EndState(flowSession.getDefinitionInternal(), "cancel");
endState.getAttributes().put("commit", Boolean.FALSE);
endState.getAttributes().put("commit", false);
flowSession.setState(endState);
jpaListener.sessionEnding(context, flowSession, "cancel", null);
jpaListener.sessionEnded(context, flowSession, "success", null);

View File

@@ -31,7 +31,7 @@ public class JpaFlowManagedPersistenceIntegrationTests extends AbstractFlowManag
public Event execute(RequestContext context) throws Exception {
assertSessionBound();
EntityManager em = (EntityManager) context.getFlowScope().get("persistenceContext");
TestBean bean = (TestBean) em.getReference(TestBean.class, new Integer(0));
TestBean bean = (TestBean) em.getReference(TestBean.class, 0);
bean.incrementCount();
assertNotNull(bean);
return new Event(this, "success");
@@ -46,7 +46,7 @@ public class JpaFlowManagedPersistenceIntegrationTests extends AbstractFlowManag
public void execute(RequestContext context, int expected) throws Exception {
assertSessionBound();
EntityManager em = (EntityManager) context.getFlowScope().get("persistenceContext");
TestBean bean = (TestBean) em.getReference(TestBean.class, new Integer(0));
TestBean bean = (TestBean) em.getReference(TestBean.class, 0);
assertEquals(expected, bean.getCount());
}
};