Class JsonJobParametersConverter
java.lang.Object
org.springframework.batch.core.converter.DefaultJobParametersConverter
org.springframework.batch.core.converter.JsonJobParametersConverter
- All Implemented Interfaces:
JobParametersConverter
Converter for
JobParameters instances that uses a JSON naming convention for
converting job parameters. The expected notation is the following:
key='{"value": "parameterStringLiteralValue",
"type":"fully.qualified.name.of.the.parameter.Type", "identifying": "booleanValue"}'
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 correct 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
- Since:
- 5.0
- Author:
- Mahmoud Ben Hassine
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record -
Field Summary
Fields inherited from class org.springframework.batch.core.converter.DefaultJobParametersConverter
conversionService -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newJsonJobParametersConverterwith a defaultObjectMapper.JsonJobParametersConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Create a newJsonJobParametersConverterwith a customObjectMapper. -
Method Summary
Modifier and TypeMethodDescriptionprotected JobParameterDecode a job parameter from a string.protected Stringencode(JobParameter<?> jobParameter) Encode a job parameter to a string.Methods inherited from class org.springframework.batch.core.converter.DefaultJobParametersConverter
getJobParameters, getProperties, setConversionService
-
Constructor Details
-
JsonJobParametersConverter
public JsonJobParametersConverter()Create a newJsonJobParametersConverterwith a defaultObjectMapper. -
JsonJobParametersConverter
public JsonJobParametersConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Create a newJsonJobParametersConverterwith a customObjectMapper.- Parameters:
objectMapper- the object mapper to use
-
-
Method Details
-
encode
Description copied from class:DefaultJobParametersConverterEncode a job parameter to a string.- Overrides:
encodein classDefaultJobParametersConverter- Parameters:
jobParameter- the parameter to encode- Returns:
- the encoded job parameter
-
decode
Description copied from class:DefaultJobParametersConverterDecode a job parameter from a string.- Overrides:
decodein classDefaultJobParametersConverter- Parameters:
encodedJobParameter- the encoded job parameter- Returns:
- the decoded job parameter
-