Class PathConstraint
java.lang.Object
io.fluxcapacitor.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 boolean
Determines whether path filtering should be performed before evaluating entry-level match criteria.getPaths()
Retrieves a list of paths associated with this constraint.boolean
Indicates whether this constraint targets specific paths in the document.boolean
Evaluates whether this constraint applies to the given document.protected abstract boolean
matches
(Document.Entry entry) Evaluates whether the specified document entry satisfies the condition defined by this method's implementation.abstract Constraint
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.common.api.search.Constraint
and, decompose, or
-
Constructor Details
-
PathConstraint
public PathConstraint()
-
-
Method Details
-
getPaths
Retrieves a list of paths associated with this constraint.- Returns:
- a list of strings representing the paths
-
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:
true
if the entry satisfies the condition;false
otherwise
-
matches
Description copied from interface:Constraint
Evaluates whether this constraint applies to the given document.- Specified by:
matches
in interfaceConstraint
- Parameters:
document
- the document to test- Returns:
true
if the constraint matches the document
-
hasPathConstraint
public boolean hasPathConstraint()Description copied from interface:Constraint
Indicates whether this constraint targets specific paths in the document.- Specified by:
hasPathConstraint
in interfaceConstraint
- Returns:
true
if 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:
true
if path filtering should be performed before evaluating entry-level criteria;false
if it should be applied after evaluating entry-level criteria.
-