- 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 imposes a minimum value.
A parameter-based repository method can impose a constraint on an
entity attribute by defining a method parameter that is of type
AtLeast or is annotated @Is(AtLeast.class) and is
of the same type or a subtype of the entity attribute. For example,
@Find
List<Car> ofYearOrHigher(@By(_Car.YEAR) AtLeast<Integer> minYear);
@Find
List<Car> yearAtLeast(@By(_Car.YEAR) @Is(AtLeast.class) int minimum,
Order<Car> sorts);
...
found = cars.ofYearOrHigher(AtLeast.min(2022));
found = cars.yearAtLeast(2023,
Order.by(_Car.price.desc()));
Repository methods can also accept AtLeast 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.greaterThanEqual(2024),
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 the minimum value allowed for the constraint target.static <V extends Comparable<?>>
AtLeast<V> min(ComparableExpression<?, V> minimum) Requires that the constraint target evaluates to a value that is greater than or equal the value to which the the givenminimumexpression evaluates.static <V extends Comparable<?>>
AtLeast<V> min(V minimum) Requires that the constraint target evaluates to a value that is greater than or equal to the givenminimum.Methods inherited from interface jakarta.data.constraint.Constraint
negate
-
Method Details
-
min
Requires that the constraint target evaluates to a value that is greater than or equal to the given
minimum. For example,found = cars.ofYearOrHigher(AtLeast.min(2021));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
minimum- the minimum value.- Returns:
- an
AtLeastconstraint. - Throws:
NullPointerException- if the minimum isnull.
-
min
Requires that the constraint target evaluates to a value that is greater than or equal the value to which the the given
minimumexpression evaluates. For example,found = cars.ofYearOrHigher(AtLeast.min(_Car.firstModelYear.plus(2)));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
minimum- an expression that evaluates to the minimum value.- Returns:
- an
AtLeastconstraint. - Throws:
NullPointerException- if the minimum isnull.
-
bound
ComparableExpression<?,V> bound()An expression that evaluates to the minimum value allowed for the constraint target.
- Returns:
- an expression representing the minimum value.
-