Class PathConstraint
java.lang.Object
io.fluxzero.common.api.search.constraints.PathConstraint
- All Implemented Interfaces:
Constraint
- Direct Known Subclasses:
BetweenConstraint, ContainsConstraint, ExistsConstraint, LookAheadConstraint, MatchConstraint, QueryConstraint
Abstract base class for constraints that apply to specific paths in a
Document.
A PathConstraint allows filtering a document based on matching criteria applied to specific
Document.Entry values at one or more paths. It forms the foundation for constraints
like MatchConstraint, BetweenConstraint, ExistsConstraint, etc.
Path Filtering
The constraint applies only to values located at the paths specified viagetPaths(). If no paths are
specified, the constraint typically matches anywhere in the document.
Performance consideration
By default, path filtering is applied after a document entry has passed the main match criteria. This order can be changed by overridingcheckPathBeforeEntry(), which applies the path check first.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanDetermines whether path filtering should be performed before evaluating entry-level match criteria.getPaths()Retrieves a list of paths associated with this constraint.booleanIndicates whether this constraint targets specific paths in the document.booleanEvaluates whether this constraint applies to the given document.protected abstract booleanmatches(Document.Entry entry, Document document) Evaluates whether the specified document entry satisfies the condition defined by this method's implementation.abstract ConstraintMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Constraint
and, decompose, or
-
Constructor Details
-
PathConstraint
public PathConstraint()
-
-
Method Details
-
getPaths
-
withPaths
-
matches
Evaluates whether the specified document entry satisfies the condition defined by this method's implementation.- Parameters:
entry- the document entry to evaluate- Returns:
trueif the entry satisfies the condition;falseotherwise
-
matches
Description copied from interface:ConstraintEvaluates whether this constraint applies to the given document.- Specified by:
matchesin interfaceConstraint- Parameters:
document- the document to test- Returns:
trueif the constraint matches the document
-
hasPathConstraint
public boolean hasPathConstraint()Description copied from interface:ConstraintIndicates whether this constraint targets specific paths in the document.- Specified by:
hasPathConstraintin interfaceConstraint- Returns:
trueif path-based filtering is involved
-
checkPathBeforeEntry
protected boolean checkPathBeforeEntry()Determines whether path filtering should be performed before evaluating entry-level match criteria.By default, path filtering is applied after a document entry satisfies the primary match criteria (`false` return). Subclasses can override this method to change the behavior so that path filtering is applied first (`true` return).
- Returns:
trueif path filtering should be performed before evaluating entry-level criteria;falseif it should be applied after evaluating entry-level criteria.
-