Skip to content

Commit 0a1cdb0

Browse files
committed
Mark fields as final where appropriate
1 parent 241e37e commit 0a1cdb0

File tree

166 files changed

+411
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+411
-365
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
*/
3737
public class JobParameter<T> implements Serializable {
3838

39-
private T value;
39+
private final T value;
4040

41-
private Class<T> type;
41+
private final Class<T> type;
4242

43-
private boolean identifying;
43+
private final boolean identifying;
4444

4545
/**
4646
* Create a new {@link JobParameter}.

spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class StepContribution implements Serializable {
4444

4545
private ExitStatus exitStatus = ExitStatus.EXECUTING;
4646

47-
private volatile StepExecution stepExecution;
47+
private final StepExecution stepExecution;
4848

4949
/**
5050
* @param execution {@link StepExecution} the stepExecution used to initialize

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AbstractApplicationContextFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public abstract class AbstractApplicationContextFactory implements ApplicationCo
5252

5353
private static final Log logger = LogFactory.getLog(AbstractApplicationContextFactory.class);
5454

55-
private Object[] resources;
55+
private final Object[] resources;
5656

5757
private ConfigurableApplicationContext parent;
5858

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/AutomaticJobRegistrar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*/
4646
public class AutomaticJobRegistrar implements Ordered, SmartLifecycle, ApplicationContextAware, InitializingBean {
4747

48-
private Collection<ApplicationContextFactory> applicationContextFactories = new ArrayList<>();
48+
private final Collection<ApplicationContextFactory> applicationContextFactories = new ArrayList<>();
4949

5050
private JobLoader jobLoader;
5151

@@ -57,7 +57,7 @@ public class AutomaticJobRegistrar implements Ordered, SmartLifecycle, Applicati
5757

5858
private boolean autoStartup = true;
5959

60-
private Object lifecycleMonitor = new Object();
60+
private final Object lifecycleMonitor = new Object();
6161

6262
private int order = Ordered.LOWEST_PRECEDENCE;
6363

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java

Lines changed: 4 additions & 4 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.
@@ -50,15 +50,15 @@
5050
*/
5151
public class DefaultJobLoader implements JobLoader, InitializingBean {
5252

53-
private static Log logger = LogFactory.getLog(DefaultJobLoader.class);
53+
private static final Log logger = LogFactory.getLog(DefaultJobLoader.class);
5454

5555
private JobRegistry jobRegistry;
5656

5757
private StepRegistry stepRegistry;
5858

59-
private Map<ApplicationContextFactory, ConfigurableApplicationContext> contexts = new ConcurrentHashMap<>();
59+
private final Map<ApplicationContextFactory, ConfigurableApplicationContext> contexts = new ConcurrentHashMap<>();
6060

61-
private Map<ConfigurableApplicationContext, Collection<String>> contextToJobNames = new ConcurrentHashMap<>();
61+
private final Map<ConfigurableApplicationContext, Collection<String>> contextToJobNames = new ConcurrentHashMap<>();
6262

6363
/**
6464
* Default constructor. Useful for declarative configuration.

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListener.java

Lines changed: 2 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.
@@ -31,7 +31,7 @@
3131
*/
3232
public class JobFactoryRegistrationListener {
3333

34-
private Log logger = LogFactory.getLog(getClass());
34+
private final Log logger = LogFactory.getLog(getClass());
3535

3636
private JobRegistry jobRegistry;
3737

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@
4848
public class JobRegistryBeanPostProcessor
4949
implements BeanPostProcessor, BeanFactoryAware, InitializingBean, DisposableBean {
5050

51-
private static Log logger = LogFactory.getLog(JobRegistryBeanPostProcessor.class);
51+
private static final Log logger = LogFactory.getLog(JobRegistryBeanPostProcessor.class);
5252

5353
// It doesn't make sense for this to have a default value...
5454
private JobRegistry jobRegistry = null;
5555

56-
private Collection<String> jobNames = new HashSet<>();
56+
private final Collection<String> jobNames = new HashSet<>();
5757

5858
private String groupName = null;
5959

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java

Lines changed: 2 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.
@@ -27,7 +27,7 @@
2727
*/
2828
public class ReferenceJobFactory implements JobFactory {
2929

30-
private Job job;
30+
private final Job job;
3131

3232
/**
3333
* @param job the {@link Job} to return from {@link #createJob()}.

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ScopeConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2022 the original author or authors.
2+
* Copyright 2021-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.
@@ -29,9 +29,9 @@
2929
@Configuration(proxyBeanMethods = false)
3030
public class ScopeConfiguration {
3131

32-
private static StepScope stepScope;
32+
private static final StepScope stepScope;
3333

34-
private static JobScope jobScope;
34+
private static final JobScope jobScope;
3535

3636
static {
3737
jobScope = new JobScope();

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

Lines changed: 2 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.
@@ -37,7 +37,7 @@
3737
*/
3838
public class JobParserJobFactoryBean implements SmartFactoryBean<FlowJob> {
3939

40-
private String name;
40+
private final String name;
4141

4242
private Boolean restartable;
4343

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
114114

115115
private PlatformTransactionManager transactionManager;
116116

117-
private Set<Object> stepExecutionListeners = new LinkedHashSet<>();
117+
private final Set<Object> stepExecutionListeners = new LinkedHashSet<>();
118118

119119
//
120120
// Flow Elements
@@ -154,7 +154,7 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
154154

155155
private Isolation isolation;
156156

157-
private Set<ChunkListener> chunkListeners = new LinkedHashSet<>();
157+
private final Set<ChunkListener> chunkListeners = new LinkedHashSet<>();
158158

159159
//
160160
// Chunk Attributes
@@ -204,13 +204,13 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
204204

205205
private ItemStream[] streams;
206206

207-
private Set<ItemReadListener<I>> readListeners = new LinkedHashSet<>();
207+
private final Set<ItemReadListener<I>> readListeners = new LinkedHashSet<>();
208208

209-
private Set<ItemWriteListener<O>> writeListeners = new LinkedHashSet<>();
209+
private final Set<ItemWriteListener<O>> writeListeners = new LinkedHashSet<>();
210210

211-
private Set<ItemProcessListener<I, O>> processListeners = new LinkedHashSet<>();
211+
private final Set<ItemProcessListener<I, O>> processListeners = new LinkedHashSet<>();
212212

213-
private Set<SkipListener<I, O>> skipListeners = new LinkedHashSet<>();
213+
private final Set<SkipListener<I, O>> skipListeners = new LinkedHashSet<>();
214214

215215
//
216216
// Additional

spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java

Lines changed: 2 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.
@@ -54,7 +54,7 @@ public abstract class AbstractJobExplorerFactoryBean implements FactoryBean<JobE
5454

5555
private TransactionAttributeSource transactionAttributeSource;
5656

57-
private ProxyFactory proxyFactory = new ProxyFactory();
57+
private final ProxyFactory proxyFactory = new ProxyFactory();
5858

5959
/**
6060
* Creates a job instance data access object (DAO).

spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean imple
7070

7171
private String tablePrefix = AbstractJdbcBatchMetadataDao.DEFAULT_TABLE_PREFIX;
7272

73-
private DataFieldMaxValueIncrementer incrementer = new AbstractDataFieldMaxValueIncrementer() {
73+
private final DataFieldMaxValueIncrementer incrementer = new AbstractDataFieldMaxValueIncrementer() {
7474
@Override
7575
protected long getNextKey() {
7676
throw new IllegalStateException("JobExplorer is read only.");

spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, In
8282

8383
private JobRepository jobRepository;
8484

85-
private CompositeJobExecutionListener listener = new CompositeJobExecutionListener();
85+
private final CompositeJobExecutionListener listener = new CompositeJobExecutionListener();
8686

8787
private JobParametersIncrementer jobParametersIncrementer;
8888

spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2019 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.
@@ -43,7 +43,7 @@
4343
*/
4444
public class SimpleJob extends AbstractJob {
4545

46-
private List<Step> steps = new ArrayList<>();
46+
private final List<Step> steps = new ArrayList<>();
4747

4848
/**
4949
* Default constructor for job with null name

spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/FlowBuilder.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-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.
@@ -47,27 +47,28 @@
4747
*
4848
* @author Dave Syer
4949
* @author Michael Minella
50+
* @author Mahmoud Ben Hassine
5051
* @since 2.2
5152
* @param <Q> the type of object returned by the builder (by default a Flow)
5253
*
5354
*/
5455
public class FlowBuilder<Q> {
5556

56-
private String name;
57+
private final String name;
5758

58-
private String prefix;
59+
private final String prefix;
5960

60-
private List<StateTransition> transitions = new ArrayList<>();
61+
private final List<StateTransition> transitions = new ArrayList<>();
6162

62-
private Map<String, State> tos = new HashMap<>();
63+
private final Map<String, State> tos = new HashMap<>();
6364

6465
private State currentState;
6566

66-
private EndState failedState;
67+
private final EndState failedState;
6768

68-
private EndState completedState;
69+
private final EndState completedState;
6970

70-
private EndState stoppedState;
71+
private final EndState stoppedState;
7172

7273
private int stepCounter = 0;
7374

@@ -79,7 +80,7 @@ public class FlowBuilder<Q> {
7980

8081
private int endCounter = 0;
8182

82-
private Map<Object, State> states = new HashMap<>();
83+
private final Map<Object, State> states = new HashMap<>();
8384

8485
private SimpleFlow flow;
8586

@@ -606,7 +607,7 @@ public static class SplitBuilder<Q> {
606607

607608
private final FlowBuilder<Q> parent;
608609

609-
private TaskExecutor executor;
610+
private final TaskExecutor executor;
610611

611612
/**
612613
* @param parent the parent builder

spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2013 the original author or authors.
2+
* Copyright 2012-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.
@@ -22,11 +22,12 @@
2222

2323
/**
2424
* @author Dave Syer
25+
* @author Mahmoud Ben Hassine
2526
*
2627
*/
2728
public class JobFlowBuilder extends FlowBuilder<FlowJobBuilder> {
2829

29-
private FlowJobBuilder parent;
30+
private final FlowJobBuilder parent;
3031

3132
public JobFlowBuilder(FlowJobBuilder parent) {
3233
super(parent.getName());

spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/SimpleJobBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2013 the original author or authors.
2+
* Copyright 2012-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.
@@ -27,12 +27,13 @@
2727

2828
/**
2929
* @author Dave Syer
30+
* @author Mahmoud Ben Hassine
3031
* @since 2.2
3132
*
3233
*/
3334
public class SimpleJobBuilder extends JobBuilderHelper<SimpleJobBuilder> {
3435

35-
private List<Step> steps = new ArrayList<>();
36+
private final List<Step> steps = new ArrayList<>();
3637

3738
private JobFlowBuilder builder;
3839

spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class FlowJob extends AbstractJob {
4242

4343
protected Flow flow;
4444

45-
private Map<String, Step> stepMap = new ConcurrentHashMap<>();
45+
private final Map<String, Step> stepMap = new ConcurrentHashMap<>();
4646

4747
private volatile boolean initialized = false;
4848

spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 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.
@@ -56,9 +56,9 @@ public class SimpleFlow implements Flow, InitializingBean {
5656

5757
private State startState;
5858

59-
private Map<String, Set<StateTransition>> transitionMap = new HashMap<>();
59+
private final Map<String, Set<StateTransition>> transitionMap = new HashMap<>();
6060

61-
private Map<String, State> stateMap = new HashMap<>();
61+
private final Map<String, State> stateMap = new HashMap<>();
6262

6363
private List<StateTransition> stateTransitions = new ArrayList<>();
6464

spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class SplitState extends AbstractState implements FlowHolder {
4646

4747
private TaskExecutor taskExecutor = new SyncTaskExecutor();
4848

49-
private FlowExecutionAggregator aggregator = new MaxValueFlowExecutionAggregator();
49+
private final FlowExecutionAggregator aggregator = new MaxValueFlowExecutionAggregator();
5050

5151
/**
5252
* @param flows collection of {@link Flow} instances.

0 commit comments

Comments
 (0)