- 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 requires exceeding a lower bound.
A parameter-based repository method can impose a constraint on an
entity attribute by defining a method parameter that is of type
GreaterThan or is annotated @Is(GreaterThan.class) and is
of the same type or a subtype of the entity attribute. For example,
@Find
List<Car> ofYearMoreThan(@By(_Car.YEAR) GreaterThan<Integer> bound);
@Find
List<Car> newerThan(@By(_Car.YEAR) @Is(GreaterThan.class) int bound,
Order<Car> sorts);
...
found = cars.ofYearMoreThan(GreaterThan.bound(2021));
found = cars.newerThan(2022,
Order.by(_Car.price.desc()));
Repository methods can also accept GreaterThan 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.greaterThan(2023),
Order.by(_Car.year.desc(),
_Car.price.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 TypeMethodDescriptionbound()An expression that evaluates to a lower bound.static <V extends Comparable<?>>
GreaterThan<V> bound(ComparableExpression<?, V> lowerBound) Requires that the constraint target evaluates to a value that is greater than the value to which the the givenlowerBoundexpression evaluates.static <V extends Comparable<?>>
GreaterThan<V> bound(V lowerBound) Requires that the constraint target evaluates to a value that is greater than or equal to the givenlowerBound.Methods inherited from interface jakarta.data.constraint.Constraint
negate
-
Method Details
-
bound
Requires that the constraint target evaluates to a value that is greater than or equal to the given
lowerBound. For example,found = cars.ofYearMoreThan(GreaterThan.bound(2020));
- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
lowerBound- an exclusive minimum value.- Returns:
- a
GreaterThanconstraint. - Throws:
NullPointerException- if the lower bound isnull.
-
bound
Requires that the constraint target evaluates to a value that is greater than the value to which the the given
lowerBoundexpression evaluates. For example,found = cars.ofYearMoreThan(GreaterThan.bound(_Car.firstModelYear.plus(1)));
- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
lowerBound- an expression that evaluates to an exclusive minimum value.- Returns:
- a
GreaterThanconstraint. - Throws:
NullPointerException- if the lower bound isnull.
-
bound
ComparableExpression<?,V> bound()An expression that evaluates to a lower bound. The constraint target must evaluate to a value greater than this bound.
- Returns:
- an expression representing the lower bound.
-