Class BetweenConstraint
java.lang.Object
io.fluxcapacitor.common.api.search.constraints.PathConstraint
io.fluxcapacitor.common.api.search.constraints.BetweenConstraint
- All Implemented Interfaces:
Constraint
A
Constraint
that filters documents based on whether a value in a specific path lies between two bounds.
The range is defined as:
- Inclusive of the lower bound (i.e.
>= min
) - Exclusive of the upper bound (i.e.
< max
)
Values are compared lexically unless they are numeric (e.g. Number
) or temporal (e.g. Instant
),
in which case they are normalized and compared accordingly.
Examples
// Matches documents where "price" is between 100 (inclusive) and 200 (exclusive)
Constraint c1 = BetweenConstraint.between(100, 200, "price");
// Matches documents where "age" is at least 18
Constraint c2 = BetweenConstraint.atLeast(18, "age");
// Matches documents with timestamps before a certain date
Constraint c3 = BetweenConstraint.below(Instant.now(), "createdAt");
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BetweenConstraint
Creates a constraint that matches values in the given path that are greater than or equal tomin
.static BetweenConstraint
Creates a constraint that matches values in the given path that are less thanmaxExclusive
.static BetweenConstraint
Creates a constraint that matches values in the given path that are greater than or equal tomin
and less thanmax
.protected boolean
Determines whether path filtering should be performed before evaluating entry-level match criteria.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
getPaths, hasPathConstraint, matches, withPaths
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
-
BetweenConstraint
public BetweenConstraint()
-
-
Method Details
-
between
public static BetweenConstraint between(Object min, Object maxExclusive, @NonNull @NonNull String path) Creates a constraint that matches values in the given path that are greater than or equal tomin
and less thanmax
.- Parameters:
min
- the inclusive lower boundmaxExclusive
- the exclusive upper boundpath
- the path in the document to compare
-
atLeast
public static BetweenConstraint atLeast(@NonNull @NonNull Object min, @NonNull @NonNull String path) Creates a constraint that matches values in the given path that are greater than or equal tomin
.- Parameters:
min
- the inclusive lower boundpath
- the path in the document to compare
-
below
public static BetweenConstraint below(@NonNull @NonNull Object maxExclusive, @NonNull @NonNull String path) Creates a constraint that matches values in the given path that are less thanmaxExclusive
.- Parameters:
maxExclusive
- the exclusive upper boundpath
- the path in the document to compare
-
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
-
checkPathBeforeEntry
protected boolean checkPathBeforeEntry()Description copied from class:PathConstraint
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).
- Overrides:
checkPathBeforeEntry
in classPathConstraint
- Returns:
true
if path filtering should be performed before evaluating entry-level criteria;false
if it should be applied after evaluating entry-level criteria.
-