Class DefaultJobParametersConverter
java.lang.Object
org.springframework.batch.core.converter.DefaultJobParametersConverter
- All Implemented Interfaces:
JobParametersConverter
- Direct Known Subclasses:
JsonJobParametersConverter
Converter for
JobParameters
instances that uses a simple naming convention for
converting job parameters. The expected notation is the following:
key=value,type,identifying
where:
- value: string literal representing the value
- type (optional): fully qualified name of the type of the value. Defaults to String.
- identifying (optional): boolean to flag the job parameter as identifying or not. Defaults to true
LocalDate
with value "2022-12-12".
The literal values are converted to the target type by using the default Spring conversion service, augmented if necessary by any custom converters. The conversion service should be configured with a converter to and from string literals to job parameter types.
By default, the Spring conversion service is augmented to support the conversion of the following types:
Date
: in theDateTimeFormatter.ISO_INSTANT
formatLocalDate
: in theDateTimeFormatter.ISO_LOCAL_DATE
formatLocalTime
: in theDateTimeFormatter.ISO_LOCAL_TIME
formatLocalDateTime
: in theDateTimeFormatter.ISO_LOCAL_DATE_TIME
format
- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.core.convert.support.ConfigurableConversionService
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected JobParameter<?>
Decode a job parameter from a string.protected String
encode
(JobParameter<?> jobParameter) Encode a job parameter to a string.getJobParameters
(Properties properties) Get a newJobParameters
instance.getProperties
(JobParameters jobParameters) The inverse operation: get aProperties
instance.void
setConversionService
(org.springframework.core.convert.support.ConfigurableConversionService conversionService) Set the conversion service to use.
-
Field Details
-
conversionService
protected org.springframework.core.convert.support.ConfigurableConversionService conversionService
-
-
Constructor Details
-
DefaultJobParametersConverter
public DefaultJobParametersConverter()
-
-
Method Details
-
getJobParameters
Description copied from interface:JobParametersConverter
Get a newJobParameters
instance. If given null or an empty properties, an empty JobParameters is returned.- Specified by:
getJobParameters
in interfaceJobParametersConverter
- Parameters:
properties
- The runtime parameters in the form of String literals.- Returns:
- a
JobParameters
object converted to the correct types. - See Also:
-
getProperties
Description copied from interface:JobParametersConverter
The inverse operation: get aProperties
instance. If given null or emptyJobParameters
, an emptyProperties
should be returned.- Specified by:
getProperties
in interfaceJobParametersConverter
- Parameters:
jobParameters
- TheJobParameters
instance to be converted.- Returns:
- a representation of the parameters as properties.
- See Also:
-
setConversionService
public void setConversionService(@NonNull org.springframework.core.convert.support.ConfigurableConversionService conversionService) Set the conversion service to use.- Parameters:
conversionService
- the conversion service to use. Must not benull
.- Since:
- 5.0
-
encode
Encode a job parameter to a string.- Parameters:
jobParameter
- the parameter to encode- Returns:
- the encoded job parameter
-
decode
Decode a job parameter from a string.- Parameters:
encodedJobParameter
- the encoded job parameter- Returns:
- the decoded job parameter
-