Class PredicateFilteringItemProcessor<T>

java.lang.Object
org.springframework.batch.item.function.PredicateFilteringItemProcessor<T>
Type Parameters:
T - type of item to process
All Implemented Interfaces:
ItemProcessor<T,T>

public class PredicateFilteringItemProcessor<T> extends Object implements ItemProcessor<T,T>
A filtering ItemProcessor that is based on a Predicate. Items for which the predicate returns true will be filtered.
Since:
5.2
Author:
Mahmoud Ben Hassine
  • Constructor Details

    • PredicateFilteringItemProcessor

      public PredicateFilteringItemProcessor(Predicate<T> predicate)
      Parameters:
      predicate - the predicate to use to filter items. Must not be null.
  • Method Details

    • process

      public T process(T item) throws Exception
      Description copied from interface: ItemProcessor
      Process the provided item, returning a potentially modified or new item for continued processing. If the returned result is null, it is assumed that processing of the item should not continue.

      A null item will never reach this method because the only possible sources are:

      • an ItemReader (which indicates no more items)
      • a previous ItemProcessor in a composite processor (which indicates a filtered item)
      Specified by:
      process in interface ItemProcessor<T,T>
      Parameters:
      item - to be processed, never null.
      Returns:
      potentially modified or new item for continued processing, null if processing of the provided item should not continue.
      Throws:
      Exception - thrown if exception occurs during processing.