Class ValidatingItemProcessor<T>

  • All Implemented Interfaces:
    ItemProcessor<T,​T>, org.springframework.beans.factory.InitializingBean
    Direct Known Subclasses:
    BeanValidatingItemProcessor

    public class ValidatingItemProcessor<T>
    extends java.lang.Object
    implements ItemProcessor<T,​T>, org.springframework.beans.factory.InitializingBean
    Simple implementation of ItemProcessor that validates input and returns it without modifications. Should the given Validator throw a ValidationException this processor will re-throw it to indicate the item should be skipped, unless setFilter(boolean) is set to true, in which case null will be returned to indicate the item should be filtered.
    Author:
    Robert Kasanicky
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidafterPropertiesSet() 
      Tprocess​(T item)
      Validate the item and return it unmodified
      voidsetFilter​(boolean filter)
      Should the processor filter invalid records instead of skipping them?
      voidsetValidator​(Validator<? super T> validator)
      Set the validator used to validate each item.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ValidatingItemProcessor

        public ValidatingItemProcessor()
        Default constructor
      • ValidatingItemProcessor

        public ValidatingItemProcessor​(Validator<? super T> validator)
        Creates a ValidatingItemProcessor based on the given Validator.
        Parameters:
        validator - the Validator instance to be used.
    • Method Detail

      • setValidator

        public void setValidator​(Validator<? super T> validator)
        Set the validator used to validate each item.
        Parameters:
        validator - the Validator instance to be used.
      • setFilter

        public void setFilter​(boolean filter)
        Should the processor filter invalid records instead of skipping them?
        Parameters:
        filter - if set to true, items that fail validation are filtered (null is returned). Otherwise, a ValidationException will be thrown.
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.lang.Exception