Skip to content

Commit c5b4f1a

Browse files
committed
Remove unnecessary boxing/unboxing
1 parent 7babb34 commit c5b4f1a

File tree

26 files changed

+62
-53
lines changed

26 files changed

+62
-53
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ else if (ns.equals("http://www.springframework.org/schema/batch")) {
172172

173173
String isAbstract = stepElement.getAttribute("abstract");
174174
if (StringUtils.hasText(isAbstract)) {
175-
bd.setAbstract(Boolean.valueOf(isAbstract));
175+
bd.setAbstract(Boolean.parseBoolean(isAbstract));
176176
}
177177

178178
String jobRepositoryRef = stepElement.getAttribute(JOB_REPO_ATTR);

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/ChunkElementParser.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@
4242
* Internal parser for the <chunk/> element inside a step.
4343
*
4444
* @author Thomas Risberg
45+
* @author Mahmoud Ben Hassine
4546
* @since 2.0
4647
*/
4748
public class ChunkElementParser {
@@ -141,7 +142,7 @@ protected void parse(Element element, AbstractBeanDefinition bd, ParserContext p
141142

142143
if (!CollectionUtils.isEmpty(exceptionClassElements)) {
143144
skippableExceptions.setMergeEnabled(exceptionClassElements.get(0).hasAttribute(MERGE_ATTR)
144-
&& Boolean.valueOf(exceptionClassElements.get(0).getAttribute(MERGE_ATTR)));
145+
&& Boolean.parseBoolean(exceptionClassElements.get(0).getAttribute(MERGE_ATTR)));
145146
}
146147
// Even if there is no retryLimit, we can still accept exception
147148
// classes for an abstract parent bean definition
@@ -167,7 +168,7 @@ protected void parse(Element element, AbstractBeanDefinition bd, ParserContext p
167168

168169
if (!CollectionUtils.isEmpty(exceptionClassElements)) {
169170
retryableExceptions.setMergeEnabled(exceptionClassElements.get(0).hasAttribute(MERGE_ATTR)
170-
&& Boolean.valueOf(exceptionClassElements.get(0).getAttribute(MERGE_ATTR)));
171+
&& Boolean.parseBoolean(exceptionClassElements.get(0).getAttribute(MERGE_ATTR)));
171172
}
172173
// Even if there is no retryLimit, we can still accept exception
173174
// classes for an abstract parent bean definition
@@ -296,7 +297,7 @@ private void handleRetryListenersElement(Element element, MutablePropertyValues
296297
parserContext.pushContainingComponent(compositeDef);
297298
ManagedList<BeanMetadataElement> retryListenerBeans = new ManagedList<>();
298299
retryListenerBeans.setMergeEnabled(listenersElement.hasAttribute(MERGE_ATTR)
299-
&& Boolean.valueOf(listenersElement.getAttribute(MERGE_ATTR)));
300+
&& Boolean.parseBoolean(listenersElement.getAttribute(MERGE_ATTR)));
300301
handleRetryListenerElements(parserContext, listenersElement, retryListenerBeans, enclosing);
301302
propertyValues.addPropertyValue("retryListeners", retryListenerBeans);
302303
parserContext.popAndRegisterContainingComponent();
@@ -319,7 +320,7 @@ private void handleStreamsElement(Element element, MutablePropertyValues propert
319320
if (streamsElement != null) {
320321
ManagedList<RuntimeBeanReference> streamBeans = new ManagedList<>();
321322
streamBeans.setMergeEnabled(streamsElement.hasAttribute(MERGE_ATTR)
322-
&& Boolean.valueOf(streamsElement.getAttribute(MERGE_ATTR)));
323+
&& Boolean.parseBoolean(streamsElement.getAttribute(MERGE_ATTR)));
323324
List<Element> streamElements = DomUtils.getChildElementsByTagName(streamsElement, "stream");
324325
if (streamElements != null) {
325326
for (Element streamElement : streamElements) {

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
3636
*
3737
* @author Thomas Risberg
3838
* @author Michael Minella
39+
* @author Mahmoud Ben Hassine
3940
*/
4041
public class CoreNamespaceUtils {
4142

@@ -202,7 +203,7 @@ public static boolean isUnderspecified(Element element) {
202203
*/
203204
public static boolean isAbstract(Element element) {
204205
String abstractAttr = element.getAttribute("abstract");
205-
return StringUtils.hasText(abstractAttr) && Boolean.valueOf(abstractAttr);
206+
return StringUtils.hasText(abstractAttr) && Boolean.parseBoolean(abstractAttr);
206207
}
207208

208209
/**

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
3636
* definition for a {@link org.springframework.batch.core.Job}.
3737
*
3838
* @author Dave Syer
39+
* @author Mahmoud Ben Hassine
3940
*
4041
*/
4142
public class JobParser extends AbstractSingleBeanDefinitionParser {
@@ -135,7 +136,7 @@ protected void doParse(Element element, ParserContext parserContext, BeanDefinit
135136
parserContext.pushContainingComponent(compositeDef);
136137
ManagedList<BeanDefinition> listeners = new ManagedList<>();
137138
listeners.setMergeEnabled(listenersElement.hasAttribute(MERGE_ATTR)
138-
&& Boolean.valueOf(listenersElement.getAttribute(MERGE_ATTR)));
139+
&& Boolean.parseBoolean(listenersElement.getAttribute(MERGE_ATTR)));
139140
List<Element> listenerElements = DomUtils.getChildElementsByTagName(listenersElement, "listener");
140141
for (Element listenerElement : listenerElements) {
141142
listeners.add(jobListenerParser.parse(listenerElement, parserContext));

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2013 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
3434
* attributes from the configuration.
3535
*
3636
* @author Dan Garrette
37+
* @author Mahmoud Ben Hassine
3738
* @since 2.0
3839
* @see AbstractListenerParser
3940
*/
@@ -78,7 +79,7 @@ public void handleListenersElement(Element stepElement, BeanDefinition beanDefin
7879
listenerBeans = (ManagedList<BeanDefinition>) propertyValues.getPropertyValue("listeners").getValue();
7980
}
8081
listenerBeans.setMergeEnabled(listenersElement.hasAttribute(MERGE_ATTR)
81-
&& Boolean.valueOf(listenersElement.getAttribute(MERGE_ATTR)));
82+
&& Boolean.parseBoolean(listenersElement.getAttribute(MERGE_ATTR)));
8283
List<Element> listenerElements = DomUtils.getChildElementsByTagName(listenersElement, "listener");
8384
if (listenerElements != null) {
8485
for (Element listenerElement : listenerElements) {

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ protected boolean isFaultTolerant() {
595595
}
596596

597597
private boolean isTrue(Boolean b) {
598-
return b != null && b.booleanValue();
598+
return b != null && b;
599599
}
600600

601601
private boolean isPositive(Integer n) {

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/TaskletParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private void handleExceptionElement(Element element, ParserContext parserContext
212212
Element exceptionClassesElement = children.get(0);
213213
ManagedList<TypedStringValue> list = new ManagedList<>();
214214
list.setMergeEnabled(exceptionClassesElement.hasAttribute(MERGE_ATTR)
215-
&& Boolean.valueOf(exceptionClassesElement.getAttribute(MERGE_ATTR)));
215+
&& Boolean.parseBoolean(exceptionClassesElement.getAttribute(MERGE_ATTR)));
216216
addExceptionClasses("include", exceptionClassesElement, list, parserContext);
217217
propertyValues.addPropertyValue(propertyName, list);
218218
}

spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private boolean parseIdentifying(String encodedJobParameter) {
190190
if (tokens.length <= 2) {
191191
return true;
192192
}
193-
return Boolean.valueOf(tokens[2]);
193+
return Boolean.parseBoolean(tokens[2]);
194194
}
195195

196196
}

spring-batch-core/src/main/java/org/springframework/batch/core/converter/JsonJobParametersConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected JobParameter decode(String encodedJobParameter) {
111111
}
112112
boolean parameterIdentifying = true;
113113
if (jobParameterDefinition.identifying() != null && !jobParameterDefinition.identifying().isEmpty()) {
114-
parameterIdentifying = Boolean.valueOf(jobParameterDefinition.identifying());
114+
parameterIdentifying = Boolean.parseBoolean(jobParameterDefinition.identifying());
115115
}
116116
Object parameterTypedValue = this.conversionService.convert(jobParameterDefinition.value(), parameterType);
117117
return new JobParameter(parameterTypedValue, parameterType, parameterIdentifying);

spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2013 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
* @author Stijn Maller
3232
* @author Lucas Ward
3333
* @author Dave Syer
34+
* @author Mahmoud Ben Hassine
3435
*/
3536

3637
public class SimpleJvmExitCodeMapper implements ExitCodeMapper {
@@ -81,7 +82,7 @@ public int intValue(String exitCode) {
8182
logger.fatal("Error mapping exit code, generic exit status returned.", ex);
8283
}
8384

84-
return (statusCode != null) ? statusCode.intValue() : JVM_EXITCODE_GENERIC_ERROR;
85+
return (statusCode != null) ? statusCode : JVM_EXITCODE_GENERIC_ERROR;
8586
}
8687

8788
}

0 commit comments

Comments
 (0)