Package org.springframework.batch.item.avro.builder

# Class AvroItemReaderBuilder<T>

java.lang.Object
org.springframework.batch.item.avro.builder.AvroItemReaderBuilder<T>

public class AvroItemReaderBuilder<T> extends Object
A builder implementation for the `AvroItemReader`.

Since:
  4.2
Author:
  David Turanski, Mahmoud Ben Hassine

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AvroItemReaderBuilder()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AvroItemReader<T>`
  `build()`
  Build an instance of `AvroItemReader`.
  `AvroItemReaderBuilder<T>`
  `currentItemCount(int currentItemCount)`
  Index for the current item.
  `AvroItemReaderBuilder<T>`
  `embeddedSchema(boolean embeddedSchema)`
  Disable or enable reading an embedded Avro schema.
  `AvroItemReaderBuilder<T>`
  `maxItemCount(int maxItemCount)`
  Configure the max number of items to be read.
  `AvroItemReaderBuilder<T>`
  `name(String name)`
  The name used to calculate the key within the `ExecutionContext`.
  `AvroItemReaderBuilder<T>`
  `resource(org.springframework.core.io.Resource resource)`
  Configure a `Resource` containing Avro serialized objects.
  `AvroItemReaderBuilder<T>`
  `saveState(boolean saveState)`
  Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
  `AvroItemReaderBuilder<T>`
  `schema(String schemaString)`
  Configure an Avro `Schema` from a String.
  `AvroItemReaderBuilder<T>`
  `schema(org.springframework.core.io.Resource schema)`
  Configure an Avro `Schema` from a `Resource`.
  `AvroItemReaderBuilder<T>`
  `type(Class<T> type)`
  Configure a type to be deserialized.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AvroItemReaderBuilder

    public AvroItemReaderBuilder()

- ## Method Details

  - ### resource

    public AvroItemReaderBuilder<T> resource(org.springframework.core.io.Resource resource)
    Configure a `Resource` containing Avro serialized objects.
    Parameters:
      `resource` - an existing Resource.
    Returns:
      The current instance of the builder.

  - ### schema

    public AvroItemReaderBuilder<T> schema(org.springframework.core.io.Resource schema)
    Configure an Avro `Schema` from a `Resource`.
    Parameters:
      `schema` - an existing schema Resource.
    Returns:
      The current instance of the builder.

  - ### schema

    public AvroItemReaderBuilder<T> schema(String schemaString)
    Configure an Avro `Schema` from a String.
    Parameters:
      `schemaString` - the schema String.
    Returns:
      The current instance of the builder.

  - ### type

    public AvroItemReaderBuilder<T> type(Class<T> type)
    Configure a type to be deserialized.
    Parameters:
      `type` - the class to be deserialized.
    Returns:
      The current instance of the builder.

  - ### embeddedSchema

    public AvroItemReaderBuilder<T> embeddedSchema(boolean embeddedSchema)
    Disable or enable reading an embedded Avro schema. True by default.
    Parameters:
      `embeddedSchema` - set to false to if the input does not contain an Avro schema.
    Returns:
      The current instance of the builder.

  - ### saveState

    public AvroItemReaderBuilder<T> saveState(boolean saveState)
    Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
    Parameters:
      `saveState` - defaults to true
    Returns:
      The current instance of the builder.

  - ### name

    public AvroItemReaderBuilder<T> name(String name)
    The name used to calculate the key within the `ExecutionContext`. Required if `saveState(boolean)` is set to true.
    Parameters:
      `name` - name of the reader instance
    Returns:
      The current instance of the builder.
    See Also:
      - `ItemStreamSupport.setName(String)`

  - ### maxItemCount

    public AvroItemReaderBuilder<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 AvroItemReaderBuilder<T> currentItemCount(int currentItemCount)
    Index for the current item. Used on restarts to indicate where to start from.
    Parameters:
      `currentItemCount` - current index
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)`

  - ### build

    public AvroItemReader<T> build()
    Build an instance of `AvroItemReader`.
    Returns:
      the instance;