Use diamond operator where appropriate

This commit is contained in:
Mahmoud Ben Hassine
2023-06-05 13:48:31 +02:00
parent 0dc5b63469
commit 92159cbc2b
105 changed files with 411 additions and 403 deletions

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.
@@ -43,6 +43,7 @@ import org.springframework.util.Assert;
* will not be called.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @param <I> the input object type
* @param <O> the output object type (will be wrapped in a Future)
* @see AsyncItemWriter
@@ -89,7 +90,7 @@ public class AsyncItemProcessor<I, O> implements ItemProcessor<I, Future<O>>, In
@Nullable
public Future<O> process(final I item) throws Exception {
final StepExecution stepExecution = getStepExecution();
FutureTask<O> task = new FutureTask<>(new Callable<O>() {
FutureTask<O> task = new FutureTask<>(new Callable<>() {
public O call() throws Exception {
if (stepExecution != null) {
StepSynchronizationManager.register(stepExecution);

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.
@@ -171,17 +171,15 @@ public class RemoteChunkHandlerFactoryBean<T> implements FactoryBean<ChunkHandle
*/
private void replaceChunkProcessor(ChunkOrientedTasklet<?> tasklet, ItemWriter<T> chunkWriter,
final StepContributionSource stepContributionSource) {
setField(tasklet, "chunkProcessor",
new SimpleChunkProcessor<T, T>(new PassThroughItemProcessor<>(), chunkWriter) {
@Override
protected void write(StepContribution contribution, Chunk<T> inputs, Chunk<T> outputs)
throws Exception {
doWrite(outputs);
// Do not update the step contribution until the chunks are
// actually processed
updateStepContribution(contribution, stepContributionSource);
}
});
setField(tasklet, "chunkProcessor", new SimpleChunkProcessor<>(new PassThroughItemProcessor<>(), chunkWriter) {
@Override
protected void write(StepContribution contribution, Chunk<T> inputs, Chunk<T> outputs) throws Exception {
doWrite(outputs);
// Do not update the step contribution until the chunks are
// actually processed
updateStepContribution(contribution, stepContributionSource);
}
});
}
/**

View File

@@ -253,7 +253,7 @@ public class MessageChannelPartitionHandler extends AbstractPartitionHandler imp
throws Exception {
final Set<StepExecution> result = new HashSet<>(split.size());
Callable<Set<StepExecution>> callback = new Callable<Set<StepExecution>>() {
Callable<Set<StepExecution>> callback = new Callable<>() {
@Override
public Set<StepExecution> call() throws Exception {
Set<Long> currentStepExecutionIds = split.stream()

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.
@@ -37,7 +37,7 @@ class AsyncItemProcessorTests {
private final AsyncItemProcessor<String, String> processor = new AsyncItemProcessor<>();
private ItemProcessor<String, String> delegate = new ItemProcessor<String, String>() {
private ItemProcessor<String, String> delegate = new ItemProcessor<>() {
@Nullable
public String process(String item) throws Exception {
return item + item;
@@ -58,7 +58,7 @@ class AsyncItemProcessorTests {
@Test
void testExecutionInStepScope() throws Exception {
delegate = new ItemProcessor<String, String>() {
delegate = new ItemProcessor<>() {
@Nullable
public String process(String item) throws Exception {
StepContext context = StepSynchronizationManager.getContext();
@@ -68,7 +68,7 @@ class AsyncItemProcessorTests {
};
processor.setDelegate(delegate);
Future<String> result = StepScopeTestUtils.doInStepScope(MetaDataInstanceFactory.createStepExecution(),
new Callable<Future<String>>() {
new Callable<>() {
public Future<String> call() throws Exception {
return processor.process("foo");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-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.
@@ -64,14 +64,14 @@ class AsyncItemWriterTests {
writer.setDelegate(new ListItemWriter(writtenItems));
Chunk<FutureTask<String>> processedItems = new Chunk<>();
processedItems.add(new FutureTask<>(new Callable<String>() {
processedItems.add(new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
return "foo";
}
}));
processedItems.add(new FutureTask<>(new Callable<String>() {
processedItems.add(new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
return "bar";
@@ -94,14 +94,14 @@ class AsyncItemWriterTests {
writer.setDelegate(new ListItemWriter(writtenItems));
Chunk<FutureTask<String>> processedItems = new Chunk<>();
processedItems.add(new FutureTask<>(new Callable<String>() {
processedItems.add(new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
return "foo";
}
}));
processedItems.add(new FutureTask<>(new Callable<String>() {
processedItems.add(new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
return null;
@@ -123,14 +123,14 @@ class AsyncItemWriterTests {
writer.setDelegate(new ListItemWriter(writtenItems));
Chunk<FutureTask<String>> processedItems = new Chunk<>();
processedItems.add(new FutureTask<>(new Callable<String>() {
processedItems.add(new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
return "foo";
}
}));
processedItems.add(new FutureTask<>(new Callable<String>() {
processedItems.add(new FutureTask<>(new Callable<>() {
@Override
public String call() throws Exception {
throw new RuntimeException("This was expected");
@@ -151,7 +151,7 @@ class AsyncItemWriterTests {
writer.setDelegate(delegate);
Chunk<Future<String>> processedItems = new Chunk<>();
processedItems.add(new Future<String>() {
processedItems.add(new Future<>() {
@Override
public boolean cancel(boolean mayInterruptIfRunning) {

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.
@@ -34,7 +34,7 @@ class ChunkProcessorChunkHandlerTests {
@Test
void testVanillaHandleChunk() throws Exception {
// given
handler.setChunkProcessor(new ChunkProcessor<Object>() {
handler.setChunkProcessor(new ChunkProcessor<>() {
public void process(StepContribution contribution, Chunk<Object> chunk) throws Exception {
count += chunk.size();
}

View File

@@ -251,7 +251,7 @@ class RemoteChunkingManagerStepBuilderTests {
}
};
ItemReader<String> itemReader = new ItemReader<String>() {
ItemReader<String> itemReader = new ItemReader<>() {
int count = 0;