Package org.springframework.batch.core
Class JobParametersBuilder
java.lang.Object
org.springframework.batch.core.JobParametersBuilder
Helper class for creating
Using the identifying flag indicates if the parameter will be used in the identification of a JobInstance. That flag defaults to true.
JobParameters
. Useful because all
JobParameter
objects are immutable, and must be instantiated separately
to ensure type safety. Once created, it can be used in the
same was a java.lang.StringBuilder (except, order is irrelevant), by adding
various parameter types and creating a valid JobParameters
once
finished.Using the identifying flag indicates if the parameter will be used in the identification of a JobInstance. That flag defaults to true.
- Since:
- 1.0
- Author:
- Lucas Ward, Michael Minella, Glenn Renfro, Mahmoud Ben Hassine
- See Also:
-
Constructor Summary
ConstructorDescriptionDefault constructor.JobParametersBuilder
(Properties properties) Constructor to add conversion capabilities to support JSR-352.JobParametersBuilder
(JobExplorer jobExplorer) JobParametersBuilder
(JobParameters jobParameters) Copy constructor.JobParametersBuilder
(JobParameters jobParameters, JobExplorer jobExplorer) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionAdd a new identifyingDate
parameter for the given key.Add a newDate
parameter for the given key.Add a new identifying Double parameter for the given key.Add a new Double parameter for the given key.addJobParameters
(JobParameters jobParameters) Copy job parameters into the current state.Add a new identifying Long parameter for the given key.Add a new Long parameter for the given key.addParameter
(String key, JobParameter jobParameter) Add a newJobParameter
for the given key.Add a new identifying String parameter for the given key.Add a new String parameter for the given key.getNextJobParameters
(Job job) Initializes theJobParameters
based on the state of theJob
.Conversion method that takes the current state of this builder and returns it as a JobParameters object.
-
Constructor Details
-
JobParametersBuilder
public JobParametersBuilder()Default constructor. Initializes the builder with empty parameters. -
JobParametersBuilder
- Parameters:
jobExplorer
-JobExplorer
used for looking up previous job parameter information
-
JobParametersBuilder
Copy constructor. Initializes the builder with the supplied parameters.- Parameters:
jobParameters
-JobParameters
instance used to initialize the builder.
-
JobParametersBuilder
Constructor to add conversion capabilities to support JSR-352. Per the spec, it is expected that all keys and values in the providedProperties
instance are Strings- Parameters:
properties
- the job parameters to be used
-
JobParametersBuilder
Copy constructor. Initializes the builder with the supplied parameters.- Parameters:
jobParameters
-JobParameters
instance used to initialize the builder.jobExplorer
-JobExplorer
used for looking up previous job parameter information
-
-
Method Details
-
addString
Add a new identifying String parameter for the given key.- Parameters:
key
- - parameter accessor.parameter
- - runtime parameter. Must not benull
.- Returns:
- a reference to this object.
-
addString
Add a new String parameter for the given key.- Parameters:
key
- - parameter accessor.parameter
- - runtime parameter. Must not benull
.identifying
- - indicates if the parameter is used as part of identifying a job instance- Returns:
- a reference to this object.
-
addDate
Add a new identifyingDate
parameter for the given key.- Parameters:
key
- - parameter accessor.parameter
- - runtime parameter. Must not benull
.- Returns:
- a reference to this object.
-
addDate
Add a newDate
parameter for the given key.- Parameters:
key
- - parameter accessor.parameter
- - runtime parameter. Must not benull
.identifying
- - indicates if the parameter is used as part of identifying a job instance- Returns:
- a reference to this object.
-
addLong
Add a new identifying Long parameter for the given key.- Parameters:
key
- - parameter accessor.parameter
- - runtime parameter. Must not benull
.- Returns:
- a reference to this object.
-
addLong
Add a new Long parameter for the given key.- Parameters:
key
- - parameter accessor.parameter
- - runtime parameter. Must not benull
.identifying
- - indicates if the parameter is used as part of identifying a job instance- Returns:
- a reference to this object.
-
addDouble
Add a new identifying Double parameter for the given key.- Parameters:
key
- - parameter accessor.parameter
- - runtime parameter. Must not benull
.- Returns:
- a reference to this object.
-
addDouble
Add a new Double parameter for the given key.- Parameters:
key
- - parameter accessor.parameter
- - runtime parameter. Must not benull
.identifying
- - indicates if the parameter is used as part of identifying a job instance- Returns:
- a reference to this object.
-
toJobParameters
Conversion method that takes the current state of this builder and returns it as a JobParameters object.- Returns:
- a valid
JobParameters
object.
-
addParameter
Add a newJobParameter
for the given key.- Parameters:
key
- - parameter accessorjobParameter
- - runtime parameter- Returns:
- a reference to this object.
-
addJobParameters
Copy job parameters into the current state.- Parameters:
jobParameters
- parameters to copy in- Returns:
- a reference to this object.
-
getNextJobParameters
Initializes theJobParameters
based on the state of theJob
. This should be called after all parameters have been entered into the builder. All parameters already set on this builder instance will be appended to those retrieved from the job incrementer, overriding any with the same key (Same behaviour asCommandLineJobRunner
with "-next" option andJobOperator.startNextInstance(String)
)- Parameters:
job
- the job for which theJobParameters
are being constructed.- Returns:
- a reference to this object.
- Since:
- 4.0
-