Class JsonItemReaderBuilder<T>
- java.lang.Object
- org.springframework.batch.item.json.builder.JsonItemReaderBuilder<T>
- Type Parameters:
T
- type of the target item
public class JsonItemReaderBuilder<T> extends java.lang.Object
A builder forJsonItemReader
.- Since:
- 4.1
- Author:
- Mahmoud Ben Hassine
Constructor Summary
Constructors Constructor Description JsonItemReaderBuilder()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonItemReader<T>
build()
Validate the configuration and build a newJsonItemReader
.JsonItemReaderBuilder<T>
currentItemCount(int currentItemCount)
Index for the current item.JsonItemReaderBuilder<T>
jsonObjectReader(JsonObjectReader<T> jsonObjectReader)
Set theJsonObjectReader
to use to read and map Json objects to domain objects.JsonItemReaderBuilder<T>
maxItemCount(int maxItemCount)
Configure the max number of items to be read.JsonItemReaderBuilder<T>
name(java.lang.String name)
The name used to calculate the key within theExecutionContext
.JsonItemReaderBuilder<T>
resource(org.springframework.core.io.Resource resource)
TheResource
to be used as input.JsonItemReaderBuilder<T>
saveState(boolean saveState)
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.JsonItemReaderBuilder<T>
strict(boolean strict)
Setting this value to true indicates that it is an error if the input does not exist and an exception will be thrown.
Method Detail
jsonObjectReader
public JsonItemReaderBuilder<T> jsonObjectReader(JsonObjectReader<T> jsonObjectReader)
Set theJsonObjectReader
to use to read and map Json objects to domain objects.- Parameters:
jsonObjectReader
- to use- Returns:
- The current instance of the builder.
- See Also:
JsonItemReader.setJsonObjectReader(JsonObjectReader)
resource
public JsonItemReaderBuilder<T> resource(org.springframework.core.io.Resource resource)
TheResource
to be used as input.- Parameters:
resource
- the input to the reader.- Returns:
- The current instance of the builder.
- See Also:
JsonItemReader.setResource(Resource)
name
public JsonItemReaderBuilder<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)
strict
public JsonItemReaderBuilder<T> strict(boolean strict)
Setting this value to true indicates that it is an error if the input does not exist and an exception will be thrown. Defaults to true.- Parameters:
strict
- indicates the input resource must exist- Returns:
- The current instance of the builder.
- See Also:
JsonItemReader.setStrict(boolean)
saveState
public JsonItemReaderBuilder<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.
maxItemCount
public JsonItemReaderBuilder<T> maxItemCount(int maxItemCount)
Configure the max number of items to be read.- Parameters:
maxItemCount
- the max items to be read- Returns:
- The current instance of the builder.
- See Also:
AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)
currentItemCount
public JsonItemReaderBuilder<T> currentItemCount(int currentItemCount)
Index for the current item. Used on restarts to indicate where to start from.- Parameters:
currentItemCount
- current index- Returns:
- The current instance of the builder.
- See Also:
AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)
build
public JsonItemReader<T> build()
Validate the configuration and build a newJsonItemReader
.- Returns:
- a new instance of the
JsonItemReader