Class JsonFileItemWriterBuilder<T>
java.lang.Object
org.springframework.batch.item.json.builder.JsonFileItemWriterBuilder<T>
- Type Parameters:
T
- type of objects to write as Json output.
Builder for
JsonFileItemWriter
.- Since:
- 4.1
- Author:
- Mahmoud Ben Hassine
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionappend
(boolean append) If set to true and the file exists, the output will be appended to the existing file.build()
Validate the configuration and build a newJsonFileItemWriter
.Encoding used for output.footerCallback
(FlatFileFooterCallback callback) A callback for footer processing.forceSync
(boolean forceSync) A flag indicating that changes should be force-synced to disk on flush.headerCallback
(FlatFileHeaderCallback callback) A callback for header processing.jsonObjectMarshaller
(JsonObjectMarshaller<T> jsonObjectMarshaller) Set theJsonObjectMarshaller
to use to marshal objects to json.lineSeparator
(String lineSeparator) String used to separate lines in output.The name used to calculate the key within theExecutionContext
.resource
(org.springframework.core.io.WritableResource resource) TheWritableResource
to be used as output.saveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.shouldDeleteIfEmpty
(boolean shouldDelete) If set to true, once the step is complete, if the resource previously provided is empty, it will be deleted.shouldDeleteIfExists
(boolean shouldDelete) If set to true, upon the start of the step, if the resource already exists, it will be deleted and recreated.transactional
(boolean transactional) If set to true, the flushing of the buffer is delayed while a transaction is active.
-
Constructor Details
-
JsonFileItemWriterBuilder
public JsonFileItemWriterBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true- Returns:
- The current instance of the builder.
-
name
The name used to calculate the key within theExecutionContext
. Required ifsaveState(boolean)
is set to true.- Parameters:
name
- name of the reader instance- Returns:
- The current instance of the builder.
- See Also:
-
forceSync
A flag indicating that changes should be force-synced to disk on flush. Defaults to false.- Parameters:
forceSync
- value to set the flag to- Returns:
- The current instance of the builder.
- See Also:
-
lineSeparator
String used to separate lines in output. Defaults to the System propertyline.separator
.- Parameters:
lineSeparator
- value to use for a line separator- Returns:
- The current instance of the builder.
- See Also:
-
jsonObjectMarshaller
public JsonFileItemWriterBuilder<T> jsonObjectMarshaller(JsonObjectMarshaller<T> jsonObjectMarshaller) Set theJsonObjectMarshaller
to use to marshal objects to json.- Parameters:
jsonObjectMarshaller
- to use- Returns:
- The current instance of the builder.
- See Also:
-
resource
TheWritableResource
to be used as output.- Parameters:
resource
- the output of the writer.- Returns:
- The current instance of the builder.
- See Also:
-
encoding
Encoding used for output.- Parameters:
encoding
- encoding type.- Returns:
- The current instance of the builder.
- See Also:
-
shouldDeleteIfEmpty
If set to true, once the step is complete, if the resource previously provided is empty, it will be deleted.- Parameters:
shouldDelete
- defaults to false- Returns:
- The current instance of the builder
- See Also:
-
shouldDeleteIfExists
If set to true, upon the start of the step, if the resource already exists, it will be deleted and recreated.- Parameters:
shouldDelete
- defaults to true- Returns:
- The current instance of the builder
- See Also:
-
append
If set to true and the file exists, the output will be appended to the existing file.- Parameters:
append
- defaults to false- Returns:
- The current instance of the builder
- See Also:
-
headerCallback
A callback for header processing.- Parameters:
callback
-FlatFileHeaderCallback
implementation- Returns:
- The current instance of the builder
- See Also:
-
transactional
If set to true, the flushing of the buffer is delayed while a transaction is active.- Parameters:
transactional
- defaults to true- Returns:
- The current instance of the builder
- See Also:
-
build
Validate the configuration and build a newJsonFileItemWriter
.- Returns:
- a new instance of the
JsonFileItemWriter
-