Class FieldFilter
java.lang.Object
com.northconcepts.datapipeline.filter.Filter
com.northconcepts.datapipeline.filter.FieldFilter
See
FieldPath for supported field name expressions.-
Constructor Summary
ConstructorsConstructorDescriptionFieldFilter(String name) FieldFilter(String... names) Creates a filter whose rules each of the given fields must pass; at least one name is required.FieldFilter(String name, FieldFilterRule... rules) Creates a filter that keeps records whose named field passes all of the given rules. -
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.addNotRule(FieldFilterRule rule) Adds a rule requiring the given rule to fail.addRule(FieldFilterRule... rules) Adds rules that every checked field must pass for the record to be kept.booleanTests whether a record passes this filter.Adds a rule requiring the field's value, as a string, to contain the given text; null values fail.Adds a rule requiring the field's date-time value to equal the givenyyyy-MM-ddoryyyy-MM-dd HH:mm[:ss[.SSS]]date to the millisecond.Adds a rule requiring the field's date-time value to equal the given date to the millisecond.dateIsAfter(String date) Adds a rule requiring the field's date-time value to be after the givenyyyy-MM-ddoryyyy-MM-dd HH:mm[:ss[.SSS]]date; null values fail.dateIsAfter(Date date) Adds a rule requiring the field's date-time value to be after the given date; null values fail.dateIsBefore(String date) Adds a rule requiring the field's date-time value to be null or before the givenyyyy-MM-ddoryyyy-MM-dd HH:mm[:ss[.SSS]]date.dateIsBefore(Date date) Adds a rule requiring the field's date-time value to be null or before the given date.booleanReturns the field most recently checked byallow(Record)or null if none was.Returns the rule most recently applied byallow(Record)(the failing one when a rule rejects the record) or null if none was.getName()Returns the field name when this filter checks exactly one field, otherwise null.getNames()getRule(int index) intinthashCode()isEmpty()Adds anIsEmptyrule to this filter.isFieldType(FieldType type) Adds a rule requiring the field to be of the givenFieldType.isInstanceOfJavaType(Class<?> type) Adds a rule requiring the field's value to be an instance of the given type or a subtype; null values fail.isJavaType(Class<?> type) Adds a rule requiring the field's value to be null or exactly of the given class (subclasses fail).Adds anIsNotEmptyrule to this filter.isNotFieldType(FieldType type) Adds a rule requiring the field not to be of the givenFieldType.isNotInstanceOfJavaType(Class<?> type) Adds a rule requiring the field's value to be null or not an instance of the given type.isNotJavaType(Class<?> type) Adds a rule requiring the field's value to be non-null and not exactly of the given class.Adds a rule requiring the field's value to be non-null.isNull()Adds a rule requiring the field's value to be null.booleanIndicates if a record missing a checked field causes an exception (the default) instead of being discarded.notContains(String value, boolean caseSensitive) Adds a rule requiring the field's value to be null or, as a string, not contain the given text.or(FieldFilterRule... rule) Adds a rule requiring at least one of the given rules to pass.patternMatches(String... regex) Adds a rule requiring the field's whole value to match one of the given regular expressions; null values fail.patternNotMatches(String... regex) Adds a rule requiring the field's value to be null or not wholly match any of the given regular expressions.setThrowExceptionOnMissingField(boolean throwExceptionOnMissingField) Indicates if a record missing a checked field causes an exception (the default) instead of being discarded.toString()<T> FieldFiltervalueMatches(T... array) Adds a rule requiring the field's value to equal one of the given values (compared withequals, so types must match).<T> FieldFiltervalueNotMatches(T... array) Adds a rule requiring the field's value to equal none of the given values (compared withequals).
-
Constructor Details
-
FieldFilter
Creates a filter whose rules each of the given fields must pass; at least one name is required. -
FieldFilter
-
FieldFilter
Creates a filter that keeps records whose named field passes all of the given rules.
-
-
Method Details
-
getCurrentRule
Returns the rule most recently applied byallow(Record)(the failing one when a rule rejects the record) or null if none was. -
getCurrentField
Returns the field most recently checked byallow(Record)or null if none was. -
getName
Returns the field name when this filter checks exactly one field, otherwise null. -
isThrowExceptionOnMissingField
public boolean isThrowExceptionOnMissingField()Indicates if a record missing a checked field causes an exception (the default) instead of being discarded. -
setThrowExceptionOnMissingField
Indicates if a record missing a checked field causes an exception (the default) instead of being discarded. -
addRule
Adds rules that every checked field must pass for the record to be kept. -
addNotRule
Adds a rule requiring the given rule to fail. -
or
Adds a rule requiring at least one of the given rules to pass. -
valueMatches
Adds a rule requiring the field's value to equal one of the given values (compared withequals, so types must match). -
valueNotMatches
Adds a rule requiring the field's value to equal none of the given values (compared withequals). -
patternMatches
Adds a rule requiring the field's whole value to match one of the given regular expressions; null values fail. -
patternNotMatches
Adds a rule requiring the field's value to be null or not wholly match any of the given regular expressions. -
contains
Adds a rule requiring the field's value, as a string, to contain the given text; null values fail. -
notContains
Adds a rule requiring the field's value to be null or, as a string, not contain the given text. -
isFieldType
Adds a rule requiring the field to be of the givenFieldType. -
isNotFieldType
Adds a rule requiring the field not to be of the givenFieldType. -
isInstanceOfJavaType
Adds a rule requiring the field's value to be an instance of the given type or a subtype; null values fail. -
isNotInstanceOfJavaType
Adds a rule requiring the field's value to be null or not an instance of the given type. -
isJavaType
Adds a rule requiring the field's value to be null or exactly of the given class (subclasses fail). -
isNotJavaType
Adds a rule requiring the field's value to be non-null and not exactly of the given class. -
IsNotNull
Adds a rule requiring the field's value to be non-null. -
isNull
Adds a rule requiring the field's value to be null. -
isEmpty
Adds anIsEmptyrule to this filter. The field will match if it is null, an empty array, or an empty/whitespace-only string.- Returns:
- this FieldFilter instance for method chaining
- See Also:
-
isNotEmpty
Adds anIsNotEmptyrule to this filter. The field will match if it is not null, not an empty array, and not an empty/whitespace-only string.- Returns:
- this FieldFilter instance for method chaining
- See Also:
-
dateIsBefore
Adds a rule requiring the field's date-time value to be null or before the given date. -
dateIsBefore
Adds a rule requiring the field's date-time value to be null or before the givenyyyy-MM-ddoryyyy-MM-dd HH:mm[:ss[.SSS]]date. -
dateIsAfter
Adds a rule requiring the field's date-time value to be after the given date; null values fail. -
dateIsAfter
Adds a rule requiring the field's date-time value to be after the givenyyyy-MM-ddoryyyy-MM-dd HH:mm[:ss[.SSS]]date; null values fail. -
dateIs
Adds a rule requiring the field's date-time value to equal the given date to the millisecond. -
dateIs
Adds a rule requiring the field's date-time value to equal the givenyyyy-MM-ddoryyyy-MM-dd HH:mm[:ss[.SSS]]date to the millisecond. -
getRuleCount
public int getRuleCount() -
getRule
-
allow
Description copied from class:FilterTests 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
-
getNames
-
toString
-
addExceptionProperties
Description copied from class:FilterAdds this filter's settings to the given exception and returns it; subclasses override it to add their own.- Overrides:
addExceptionPropertiesin classFilter
-
hashCode
public int hashCode() -
equals
-