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_INSTANTformatLocalDate: in theDateTimeFormatter.ISO_LOCAL_DATEformatLocalTime: in theDateTimeFormatter.ISO_LOCAL_TIMEformatLocalDateTime: in theDateTimeFormatter.ISO_LOCAL_DATE_TIMEformat
- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.core.convert.support.ConfigurableConversionService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected JobParameter<?>Decode a job parameter from a string.protected Stringencode(JobParameter<?> jobParameter) Encode a job parameter to a string.getJobParameters(Properties properties) Get a newJobParametersinstance.getProperties(JobParameters jobParameters) The inverse operation: get aPropertiesinstance.voidsetConversionService(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:JobParametersConverterGet a newJobParametersinstance. If given null or an empty properties, an empty JobParameters is returned.- Specified by:
getJobParametersin interfaceJobParametersConverter- Parameters:
properties- The runtime parameters in the form of String literals.- Returns:
- a
JobParametersobject converted to the correct types. - See Also:
-
getProperties
Description copied from interface:JobParametersConverterThe inverse operation: get aPropertiesinstance. If given null or emptyJobParameters, an emptyPropertiesshould be returned.- Specified by:
getPropertiesin interfaceJobParametersConverter- Parameters:
jobParameters- TheJobParametersinstance 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
-