Class ExistsConstraint
java.lang.Object
io.fluxcapacitor.common.api.search.constraints.PathConstraint
io.fluxcapacitor.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");
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Constraint
Creates a constraint that checks for the presence of any of the given paths.protected boolean
matches
(Document.Entry entry) Evaluates whether the specified document entry satisfies the condition defined by this method's implementation.Methods inherited from class io.fluxcapacitor.common.api.search.constraints.PathConstraint
checkPathBeforeEntry, getPaths, hasPathConstraint, matches
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
-
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:PathConstraint
Evaluates whether the specified document entry satisfies the condition defined by this method's implementation.- Specified by:
matches
in classPathConstraint
- Parameters:
entry
- the document entry to evaluate- Returns:
true
if the entry satisfies the condition;false
otherwise
-
withPaths
- Specified by:
withPaths
in classPathConstraint
-