org.springframework.batch.core.job

## Class DefaultJobParametersValidator

- java.lang.Object
- - org.springframework.batch.core.job.DefaultJobParametersValidator

- All Implemented Interfaces:
    JobParametersValidator, org.springframework.beans.factory.InitializingBean

      public class DefaultJobParametersValidator
      extends java.lang.Object
      implements JobParametersValidator, org.springframework.beans.factory.InitializingBean

  Default implementation of `JobParametersValidator`.
  Author:
    Dave Syer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultJobParametersValidator()` Convenient default constructor for unconstrained validation.
    `DefaultJobParametersValidator(java.lang.String[] requiredKeys, java.lang.String[] optionalKeys)` Create a new validator with the required and optional job parameter keys provided.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Check that there are no overlaps between required and optional keys.
    `void` | `setOptionalKeys(java.lang.String[] optionalKeys)` The keys that are optional in the parameters.
    `void` | `setRequiredKeys(java.lang.String[] requiredKeys)` The keys that are required in the parameters.
    `void` | `validate(JobParameters parameters)` Check the parameters meet the specification provided.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultJobParametersValidator

          public DefaultJobParametersValidator()

      Convenient default constructor for unconstrained validation.

    - #### DefaultJobParametersValidator

          public DefaultJobParametersValidator(java.lang.String[] requiredKeys,
                                               java.lang.String[] optionalKeys)

      Create a new validator with the required and optional job parameter keys provided.
      Parameters:
        `requiredKeys` - the required keys
        `optionalKeys` - the optional keys
      See Also:
        `setOptionalKeys(String[])`, `setRequiredKeys(String[])`

  - ### Method Detail

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws java.lang.IllegalStateException

      Check that there are no overlaps between required and optional keys.
      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
      Throws:
        `java.lang.IllegalStateException` - if there is an overlap

    - #### validate

          public void validate(JobParameters parameters)
                        throws JobParametersInvalidException

      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 interface `JobParametersValidator`
      Parameters:
        `parameters` - some `JobParameters`
      Throws:
        `JobParametersInvalidException` - if the parameters are not valid
      See Also:
        `JobParametersValidator.validate(JobParameters)`

    - #### setRequiredKeys

          public final void setRequiredKeys(java.lang.String[] requiredKeys)

      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(String[])`

    - #### setOptionalKeys

          public final void setOptionalKeys(java.lang.String[] optionalKeys)

      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:
        `setRequiredKeys(String[])`