Class ConsumerItemWriter<T>

java.lang.Object
org.springframework.batch.item.function.ConsumerItemWriter<T>
Type Parameters:
T - type of items to write
All Implemented Interfaces:
ItemWriter<T>

public class ConsumerItemWriter<T> extends Object implements ItemWriter<T>
Adapter for a Consumer to an ItemWriter.
Since:
5.2
Author:
Mahmoud Ben Hassine
  • Constructor Details

    • ConsumerItemWriter

      public ConsumerItemWriter(Consumer<T> consumer)
      Create a new ConsumerItemWriter.
      Parameters:
      consumer - the consumer to use to write items. Must not be null.
  • Method Details

    • write

      public void write(Chunk<? extends T> items) throws Exception
      Description copied from interface: ItemWriter
      Process the supplied data element. Will not be called with any null items in normal operation.
      Specified by:
      write in interface ItemWriter<T>
      Parameters:
      items - of items to be written. Must not be null.
      Throws:
      Exception - if there are errors. The framework will catch the exception and convert or rethrow it as appropriate.