Class Filter
java.lang.Object
com.northconcepts.datapipeline.filter.Filter
- Direct Known Subclasses:
FieldCount,FieldExists,FieldFilter,FieldNotExists,FilterExpression,SchemaFilter
Base class for conditions that decide whether a record is kept or discarded, for example by a
FilteringReader.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this filter's settings to the given exception and returns it; subclasses override it to add their own.abstract booleanTests whether a record passes this filter.protected voidclose()Called byFilteringReaderwhenFilteringReader.close()is called (after reading ends).static FilterCreates a Filter from a Java Predicate.protected voidopen()Called byFilteringReaderwhenFilteringReader.open()is called (before reading starts).
-
Constructor Details
-
Filter
public Filter()
-
-
Method Details
-
addExceptionProperties
Adds this filter's settings to the given exception and returns it; subclasses override it to add their own. -
open
protected void open()Called byFilteringReaderwhenFilteringReader.open()is called (before reading starts). -
close
protected void close()Called byFilteringReaderwhenFilteringReader.close()is called (after reading ends). -
allow
Tests whether a record passes this filter.Contract for subclasses (see also
docs/authoring/Filter.md):- Return
trueto keep the record. - Return
falseto discard the record (routed to a discard writer if the hostFilteringReaderis configured with one). - Must be a pure decision — do not mutate the record here.
- Throw
DataExceptiononly for unrecoverable filter failures; for ordinary "data fails predicate" cases, returnfalse.
- Return
-
of
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
-