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

public abstract class PathConstraint extends Object implements Constraint
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 via getPaths(). 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 overriding checkPathBeforeEntry(), which applies the path check first.
See Also:
  • Constructor Details

    • PathConstraint

      public PathConstraint()
  • Method Details

    • getPaths

      public abstract List<String> getPaths()
      Retrieves a list of paths associated with this constraint.
      Returns:
      a list of strings representing the paths
    • withPaths

      public abstract Constraint withPaths(List<String> paths)
    • matches

      protected abstract boolean matches(Document.Entry entry)
      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

      public boolean matches(Document document)
      Description copied from interface: Constraint
      Evaluates whether this constraint applies to the given document.
      Specified by:
      matches in interface Constraint
      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 interface Constraint
      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.