java.lang.Object
com.northconcepts.datapipeline.filter.Filter
Direct Known Subclasses:
FieldCount, FieldExists, FieldFilter, FieldNotExists, FilterExpression, SchemaFilter

public abstract class Filter extends Object
Base class for conditions that decide whether a record is kept or discarded, for example by a FilteringReader.
  • Constructor Details

    • Filter

      public Filter()
  • Method Details

    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Adds this filter's settings to the given exception and returns it; subclasses override it to add their own.
    • open

      protected void open()
      Called by FilteringReader when FilteringReader.open() is called (before reading starts).
    • close

      protected void close()
      Called by FilteringReader when FilteringReader.close() is called (after reading ends).
    • allow

      public abstract boolean allow(Record record)
      Tests whether a record passes this filter.

      Contract for subclasses (see also docs/authoring/Filter.md):

      • Return true to keep the record.
      • Return false to discard the record (routed to a discard writer if the host FilteringReader is configured with one).
      • Must be a pure decision — do not mutate the record here.
      • Throw DataException only for unrecoverable filter failures; for ordinary "data fails predicate" cases, return false.
    • of

      public static Filter of(Predicate<Record> predicate)
      Creates a Filter from a Java Predicate. This allows creation of filters using lambda expressions or method references.
      Parameters:
      predicate - the predicate that tests records
      Returns:
      a Filter that delegates to the predicate