Remove unnecessary boxing/unboxing

This commit is contained in:
Mahmoud Ben Hassine
2023-06-12 16:17:32 +02:00
parent 7babb341f5
commit c5b4f1a777
26 changed files with 62 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ import org.springframework.util.Assert;
* representing the {@link Void#TYPE}).
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*/
public class RepeatOperationsInterceptor implements MethodInterceptor {
@@ -132,7 +133,7 @@ public class RepeatOperationsInterceptor implements MethodInterceptor {
* @return
*/
private boolean isComplete(Object result) {
return result == null || (result instanceof Boolean) && !((Boolean) result).booleanValue();
return result == null || (result instanceof Boolean) && !(Boolean) result;
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ public class IntArrayPropertyEditor extends PropertyEditorSupport {
String[] strs = StringUtils.commaDelimitedListToStringArray(text);
int[] value = new int[strs.length];
for (int i = 0; i < value.length; i++) {
value[i] = Integer.valueOf(strs[i].trim()).intValue();
value[i] = Integer.parseInt(strs[i].trim());
}
setValue(value);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test;
/**
* @author Lucas Ward
* @author Will Schipp
* @author Mahmoud Ben Hassine
*/
class ColumnMapExecutionContextRowMapperTests {
@@ -42,8 +43,8 @@ class ColumnMapExecutionContextRowMapperTests {
mapper = new ColumnMapItemPreparedStatementSetter();
key = new LinkedHashMap<>(2);
key.put("1", Integer.valueOf(1));
key.put("2", Integer.valueOf(2));
key.put("1", 1);
key.put("2", 2);
}
@Test
@@ -55,8 +56,8 @@ class ColumnMapExecutionContextRowMapperTests {
@Test
void testCreateSetter() throws Exception {
ps.setObject(1, Integer.valueOf(1));
ps.setObject(2, Integer.valueOf(2));
ps.setObject(1, 1);
ps.setObject(2, 2);
mapper.setValues(key, ps);
}

View File

@@ -38,7 +38,7 @@ public class FlatFileItemReaderCommonTests extends AbstractItemStreamItemReaderT
@Override
public Foo mapLine(String line, int lineNumber) {
Foo foo = new Foo();
foo.setValue(Integer.valueOf(line.trim()));
foo.setValue(Integer.parseInt(line.trim()));
return foo;
}
});

View File

@@ -37,7 +37,7 @@ class MultiResourceItemReaderFlatFileTests extends AbstractItemStreamItemReaderT
@Override
public Foo mapLine(String line, int lineNumber) throws Exception {
Foo foo = new Foo();
foo.setValue(Integer.valueOf(line));
foo.setValue(Integer.parseInt(line));
return foo;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 the original author or authors.
* Copyright 2016-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -223,8 +223,8 @@ class FlatFileItemReaderBuilderTests {
.fieldSetMapper(fieldSet -> {
Foo item = new Foo();
item.setFirst(Integer.valueOf(fieldSet.readString(0).replaceAll("\\|", "")));
item.setSecond(Integer.valueOf(fieldSet.readString(1).replaceAll("\\|", "")));
item.setFirst(Integer.parseInt(fieldSet.readString(0).replaceAll("\\|", "")));
item.setSecond(Integer.parseInt(fieldSet.readString(1).replaceAll("\\|", "")));
item.setThird(fieldSet.readString(2).replaceAll("\\|", ""));
return item;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 the original author or authors.
* Copyright 2017-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.mock;
/**
* @author Glenn Renfro
* @author Mahmoud Ben Hassine
*/
class MultiResourceItemReaderBuilderTests extends AbstractItemStreamItemReaderTests {
@@ -45,7 +46,7 @@ class MultiResourceItemReaderBuilderTests extends AbstractItemStreamItemReaderTe
fileReader.setLineMapper((line, lineNumber) -> {
Foo foo = new Foo();
foo.setValue(Integer.valueOf(line));
foo.setValue(Integer.parseInt(line));
return foo;
});
fileReader.setSaveState(true);

View File

@@ -28,6 +28,7 @@ import org.springframework.lang.Nullable;
/**
* @author Jimmy Praet
* @author Mahmoud Ben Hassine
*/
class ClassifierCompositeItemProcessorTests {
@@ -98,9 +99,9 @@ class ClassifierCompositeItemProcessorTests {
classifier.setTypeMap(typeMap);
processor.setClassifier(classifier);
assertEquals("int: 1", processor.process(Integer.valueOf(1)).toString());
assertEquals("long: 2", processor.process(Long.valueOf(2)).toString());
assertEquals("number: 3", processor.process(Byte.valueOf((byte) 3)).toString());
assertEquals("int: 1", processor.process(1).toString());
assertEquals("long: 2", processor.process(2L).toString());
assertEquals("number: 3", processor.process((byte) 3).toString());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -249,7 +249,7 @@ class RepeatOperationsInterceptorTests {
public Object service() throws Exception {
count++;
if (count <= maxService) {
return Integer.valueOf(count);
return count;
}
else {
return null;