Package org.springframework.batch.core
Class JobParametersBuilder
java.lang.Object
org.springframework.batch.core.JobParametersBuilder
Helper class for creating
Using the
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
StringBuilder (except that order is irrelevant), by adding various
parameter types and creating a valid JobParameters object once finished.Using the
identifying flag indicates if the parameter should be used in the
identification of a JobInstance object. That flag defaults to true.- Since:
- 1.0
- Author:
- Lucas Ward, Michael Minella, Glenn Renfro, Mahmoud Ben Hassine
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault 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 identifyingDateparameter for the given key.Add a newDateparameter for the given key.Add a new identifyingDoubleparameter for the given key.Add a newDoubleparameter for the given key.addJobParameters(JobParameters jobParameters) Copy job parameters into the current state.Add a new identifyingLongparameter for the given key.Add a newLongparameter for the given key.addParameter(String key, JobParameter jobParameter) Add a newJobParameterfor 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 theJobParametersbased on the state of theJob.Conversion method that takes the current state of this builder and returns it as aJobParametersobject.
-
Constructor Details
-
JobParametersBuilder
public JobParametersBuilder()Default constructor. Initializes the builder with empty parameters. -
JobParametersBuilder
- Parameters:
jobExplorer-JobExplorerused for looking up previous job parameter information.
-
JobParametersBuilder
Copy constructor. Initializes the builder with the supplied parameters.- Parameters:
jobParameters-JobParametersinstance 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 providedPropertiesinstance areStringobjects.- Parameters:
properties- the job parameters to be used.
-
JobParametersBuilder
Copy constructor. Initializes the builder with the supplied parameters.- Parameters:
jobParameters-JobParametersinstance used to initialize the builder.jobExplorer-JobExplorerused for looking up previous job parameter information.
-
-
Method Details
-
addString
Add a new identifying String parameter for the given key.- Parameters:
key- The parameter accessor.parameter- The runtime parameter. Must not benull.- Returns:
- a reference to this object.
-
addString
Add a new String parameter for the given key.- Parameters:
key- The parameter accessor.parameter- The runtime parameter. Must not benull.identifying- The indicates if the parameter is used as part of identifying a job instance.- Returns:
- a reference to this object.
-
addDate
Add a new identifyingDateparameter for the given key.- Parameters:
key- The parameter accessor.parameter- The runtime parameter. Must not benull.- Returns:
- a reference to this object.
-
addDate
Add a newDateparameter for the given key.- Parameters:
key- The parameter accessor.parameter- The 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 identifyingLongparameter for the given key.- Parameters:
key- The parameter accessor.parameter- The runtime parameter. Must not benull.- Returns:
- a reference to this object.
-
addLong
Add a newLongparameter for the given key.- Parameters:
key- The parameter accessor.parameter- The 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 identifyingDoubleparameter for the given key.- Parameters:
key- The parameter accessor.parameter- The runtime parameter. Must not benull.- Returns:
- a reference to this object.
-
addDouble
Add a newDoubleparameter for the given key.- Parameters:
key- The parameter accessor.parameter- The 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 aJobParametersobject.- Returns:
- a valid
JobParametersobject.
-
addParameter
Add a newJobParameterfor the given key.- Parameters:
key- The parameter accessor.jobParameter- The runtime parameter.- Returns:
- a reference to this object.
-
addJobParameters
Copy job parameters into the current state.- Parameters:
jobParameters- The parameters to copy in.- Returns:
- a reference to this object.
-
getNextJobParameters
Initializes theJobParametersbased 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 are appended to those retrieved from the job incrementer, overriding any with the same key (this is the same behavior asCommandLineJobRunnerwith the-nextoption andJobOperator.startNextInstance(String)).- Parameters:
job- The job for which theJobParametersare being constructed.- Returns:
- a reference to this object.
- Since:
- 4.0
-