Class DefaultJobParametersValidator
java.lang.Object
org.springframework.batch.core.job.DefaultJobParametersValidator
- All Implemented Interfaces:
JobParametersValidator
,org.springframework.beans.factory.InitializingBean
public class DefaultJobParametersValidator
extends Object
implements JobParametersValidator, org.springframework.beans.factory.InitializingBean
Default implementation of
JobParametersValidator
.- Author:
- Dave Syer, Mahmoud Ben Hassine
-
Constructor Summary
ConstructorDescriptionConvenient default constructor for unconstrained validation.DefaultJobParametersValidator
(String[] requiredKeys, String[] optionalKeys) Create a new validator with the required and optional job parameter keys provided. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Check that there are no overlaps between required and optional keys.final void
setOptionalKeys
(String[] optionalKeys) The keys that are optional in the parameters.final void
setRequiredKeys
(String[] requiredKeys) The keys that are required in the parameters.void
validate
(JobParameters parameters) Check the parameters meet the specification provided.
-
Constructor Details
-
DefaultJobParametersValidator
public DefaultJobParametersValidator()Convenient default constructor for unconstrained validation. -
DefaultJobParametersValidator
Create a new validator with the required and optional job parameter keys provided.- Parameters:
requiredKeys
- the required keysoptionalKeys
- the optional keys- See Also:
-
-
Method Details
-
afterPropertiesSet
Check that there are no overlaps between required and optional keys.- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
IllegalStateException
- if there is an overlap
-
validate
Check the parameters meet the specification provided. If optional keys are explicitly specified then all keys must be in that list, or in the required list. Otherwise all keys that are specified as required must be present.- Specified by:
validate
in interfaceJobParametersValidator
- Parameters:
parameters
- someJobParameters
(can benull
)- Throws:
JobParametersInvalidException
- if the parameters are not valid- See Also:
-
setRequiredKeys
The keys that are required in the parameters. The default is empty, meaning that all parameters are optional, unless optional keys are explicitly specified.- Parameters:
requiredKeys
- the required key values- See Also:
-
setOptionalKeys
The keys that are optional in the parameters. If any keys are explicitly optional, then to be valid all other keys must be explicitly required. The default is empty, meaning that all parameters that are not required are optional.- Parameters:
optionalKeys
- the optional key values- See Also:
-