- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.
- All Superinterfaces:
Constraint<V>
A constraint that excludes values within a range.
A parameter-based repository method can impose a constraint on an
entity attribute by defining a method parameter that is of type
NotBetween and is of the same type or a subtype of the entity
attribute. For example,
@Find
List<Car> byModelYear(@By(_Car.YEAR) NotBetween<Integer> yearsToExclude);
...
found = cars.byModelYear(NotBetween.bounds(2020, 2022));
Repository methods can also accept NotBetween constraints at
run time in the form of a Restriction on a
ComparableExpression. For example,
@Find
List<Car> searchAll(Restriction<Car> restrict, Order<Car> sorts);
...
found = cars.searchAll(_Car.year.notBetween(2019, 2021),
Order.by(_Car.year.desc(),
_Car.price.desc(),
_Car.vin.asc()));
The entity and static metamodel for the code
examples within this class are shown in the Attribute Javadoc.
- Since:
- 1.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V extends Comparable<?>>
NotBetween<V> bounds(ComparableExpression<?, V> lower, ComparableExpression<?, V> upper) Requires that the constraint target evaluates to a value that is less than the value to which the givenlowerexpression evaluates or greater than the value to which the givenupperexpression evaluates.static <V extends Comparable<?>>
NotBetween<V> bounds(ComparableExpression<?, V> lower, V upper) Requires that the constraint target evaluates to a value that is less than the value to which the givenlowerexpression evaluates or greater than the givenupperbound.static <V extends Comparable<?>>
NotBetween<V> bounds(V lower, ComparableExpression<?, V> upper) Requires that the constraint target evaluates to a value that is less than the givenlowerbound or greater than the value to which the givenupperexpression evaluates.static <V extends Comparable<?>>
NotBetween<V> bounds(V lower, V upper) Requires that the constraint target evaluates to a value that is less than the givenlowerbound or greater than the givenupperbound.An expression that evaluates to the minimum value excluded for the constraint target.An expression that evaluates to the maximum value excluded for the constraint target.Methods inherited from interface jakarta.data.constraint.Constraint
negate
-
Method Details
-
bounds
Requires that the constraint target evaluates to a value that is less than the given
lowerbound or greater than the givenupperbound. For example,found = cars.byModelYear(NotBetween.bounds(2022, 2024));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
lower- the lower bound of the range to exclude.upper- the upper bound of the range to exclude.- Returns:
- a
NotBetweenconstraint. - Throws:
NullPointerException- if the lower or upper bound isnull.
-
bounds
Requires that the constraint target evaluates to a value that is less than the given
lowerbound or greater than the value to which the givenupperexpression evaluates. For example,found = cars.byModelYear(NotBetween.bounds(2015, _Car.firstModelYear.plus(5)));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
lower- the lower bound of the range to exclude.upper- an expression that evaluates to the upper bound of the range to exclude.- Returns:
- a
NotBetweenconstraint. - Throws:
NullPointerException- if lower or upper isnull.
-
bounds
Requires that the constraint target evaluates to a value that is less than the value to which the given
lowerexpression evaluates or greater than the givenupperbound. For example,found = cars.byModelYear(NotBetween.bounds(_Car.firstModelYear, 2022));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
lower- an expression that evaluates to the lower bound of the range to exclude.upper- the upper bound of the range to exclude.- Returns:
- a
NotBetweenconstraint. - Throws:
NullPointerException- if lower or upper isnull.
-
bounds
static <V extends Comparable<?>> NotBetween<V> bounds(ComparableExpression<?, V> lower, ComparableExpression<?, V> upper) Requires that the constraint target evaluates to a value that is less than the value to which the given
lowerexpression evaluates or greater than the value to which the givenupperexpression evaluates. For example,found = cars.byModelYear(NotBetween.bounds(_Car.firstModelYear, _Car.firstModelYear.plus(2)));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
lower- an expression that evaluates to the lower bound of the range to exclude.upper- an expression that evaluates to the upper bound of the range to exclude.- Returns:
- a
NotBetweenconstraint. - Throws:
NullPointerException- if lower or upper isnull.
-
lowerBound
ComparableExpression<?,V> lowerBound()An expression that evaluates to the minimum value excluded for the constraint target.
- Returns:
- an expression representing the minimum value excluded.
-
upperBound
ComparableExpression<?,V> upperBound()An expression that evaluates to the maximum value excluded for the constraint target.
- Returns:
- an expression representing the maximum value excluded.
-