Class ExistsConstraint
java.lang.Object
io.fluxzero.common.api.search.constraints.PathConstraint
io.fluxzero.common.api.search.constraints.ExistsConstraint
- All Implemented Interfaces:
Constraint
A
Constraint that checks whether one or more paths exist in a document.
This constraint matches any document that contains a non-null value at the specified path(s).
If multiple paths are provided, the constraint will match if any of them are present (i.e. this behaves as
an AnyConstraint).
Optionally, sub-paths can be included using a glob-style match with /**.
Examples
// Matches documents where "person/firstName" exists (is non-null)
Constraint c1 = ExistsConstraint.exists("person/firstName");
// Matches if any of the specified paths or their children exist
Constraint c2 = ExistsConstraint.exists(true, "address", "email");
Note: to speed up ExistsConstraint matching, it is recommended to annotate fields with Sortable.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConstraintCreates a constraint that checks for the presence of any of the given paths.protected booleanmatches(Document.Entry entry, Document document) Evaluates whether the specified document entry satisfies the condition defined by this method's implementation.Methods inherited from class PathConstraint
checkPathBeforeEntry, getPaths, hasPathConstraint, matchesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Constraint
and, decompose, or
-
Constructor Details
-
ExistsConstraint
public ExistsConstraint()
-
-
Method Details
-
exists
Creates a constraint that checks for the presence of any of the given paths. Sub-paths will be included.- Parameters:
paths- the paths to check for existence- Returns:
- a constraint that matches if any of the given paths (or their sub-paths) exist
-
matches
Description copied from class:PathConstraintEvaluates whether the specified document entry satisfies the condition defined by this method's implementation.- Specified by:
matchesin classPathConstraint- Parameters:
entry- the document entry to evaluate- Returns:
trueif the entry satisfies the condition;falseotherwise
-
withPaths
- Specified by:
withPathsin classPathConstraint
-