Package com.redis.riot.core.resource
Class JsonResourceItemWriterBuilder<T>
- java.lang.Object
-
- com.redis.riot.core.resource.JsonResourceItemWriterBuilder<T>
-
- Type Parameters:
T
- type of objects to write as Json output.
public class JsonResourceItemWriterBuilder<T> extends java.lang.Object
Builder forJsonResourceItemWriter
.- Since:
- 4.1
- Author:
- Mahmoud Ben Hassine
-
-
Constructor Summary
Constructors Constructor Description JsonResourceItemWriterBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonResourceItemWriterBuilder<T>
append(boolean append)
If set to true and the file exists, the output will be appended to the existing file.JsonResourceItemWriter<T>
build()
Validate the configuration and build a newJsonResourceItemWriter
.JsonResourceItemWriterBuilder<T>
encoding(java.lang.String encoding)
Encoding used for output.JsonResourceItemWriterBuilder<T>
footerCallback(org.springframework.batch.item.file.FlatFileFooterCallback callback)
A callback for footer processing.JsonResourceItemWriterBuilder<T>
headerCallback(org.springframework.batch.item.file.FlatFileHeaderCallback callback)
A callback for header processing.JsonResourceItemWriterBuilder<T>
jsonObjectMarshaller(org.springframework.batch.item.json.JsonObjectMarshaller<T> jsonObjectMarshaller)
Set theJsonObjectMarshaller
to use to marshal objects to json.JsonResourceItemWriterBuilder<T>
lineSeparator(java.lang.String lineSeparator)
String used to separate lines in output.JsonResourceItemWriterBuilder<T>
name(java.lang.String name)
The name used to calculate the key within theExecutionContext
.JsonResourceItemWriterBuilder<T>
resource(org.springframework.core.io.Resource resource)
TheResource
to be used as output.JsonResourceItemWriterBuilder<T>
saveState(boolean saveState)
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.JsonResourceItemWriterBuilder<T>
shouldDeleteIfEmpty(boolean shouldDelete)
If set to true, once the step is complete, if the resource previously provided is empty, it will be deleted.JsonResourceItemWriterBuilder<T>
shouldDeleteIfExists(boolean shouldDelete)
If set to true, upon the start of the step, if the resource already exists, it will be deleted and recreated.
-
-
-
Method Detail
-
saveState
public JsonResourceItemWriterBuilder<T> saveState(boolean 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
public JsonResourceItemWriterBuilder<T> name(java.lang.String 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:
ItemStreamSupport.setName(String)
-
lineSeparator
public JsonResourceItemWriterBuilder<T> lineSeparator(java.lang.String 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:
AbstractResourceItemWriter.setLineSeparator(String)
-
jsonObjectMarshaller
public JsonResourceItemWriterBuilder<T> jsonObjectMarshaller(org.springframework.batch.item.json.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:
JsonResourceItemWriter.setJsonObjectMarshaller(JsonObjectMarshaller)
-
resource
public JsonResourceItemWriterBuilder<T> resource(org.springframework.core.io.Resource resource)
TheResource
to be used as output.- Parameters:
resource
- the output of the writer.- Returns:
- The current instance of the builder.
- See Also:
AbstractResourceItemWriter.setResource(Resource)
-
encoding
public JsonResourceItemWriterBuilder<T> encoding(java.lang.String encoding)
Encoding used for output.- Parameters:
encoding
- encoding type.- Returns:
- The current instance of the builder.
- See Also:
AbstractResourceItemWriter.setEncoding(String)
-
shouldDeleteIfEmpty
public JsonResourceItemWriterBuilder<T> shouldDeleteIfEmpty(boolean shouldDelete)
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:
AbstractResourceItemWriter.setShouldDeleteIfEmpty(boolean)
-
shouldDeleteIfExists
public JsonResourceItemWriterBuilder<T> shouldDeleteIfExists(boolean shouldDelete)
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:
AbstractResourceItemWriter.setShouldDeleteIfExists(boolean)
-
append
public JsonResourceItemWriterBuilder<T> append(boolean 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:
AbstractResourceItemWriter.setAppendAllowed(boolean)
-
headerCallback
public JsonResourceItemWriterBuilder<T> headerCallback(org.springframework.batch.item.file.FlatFileHeaderCallback callback)
A callback for header processing.- Parameters:
callback
-FlatFileHeaderCallback
implementation- Returns:
- The current instance of the builder
- See Also:
AbstractResourceItemWriter.setHeaderCallback(FlatFileHeaderCallback)
-
footerCallback
public JsonResourceItemWriterBuilder<T> footerCallback(org.springframework.batch.item.file.FlatFileFooterCallback callback)
A callback for footer processing.- Parameters:
callback
-FlatFileFooterCallback
implementation- Returns:
- The current instance of the builder
- See Also:
AbstractResourceItemWriter.setFooterCallback(FlatFileFooterCallback)
-
build
public JsonResourceItemWriter<T> build()
Validate the configuration and build a newJsonResourceItemWriter
.- Returns:
- a new instance of the
JsonResourceItemWriter
-
-