- 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 a non-null value.
A parameter-based repository method can impose a constraint on an
entity attribute by defining a method parameter that is of type
NotNull. For example,
@Find
List<Car> listedRecently(@By(_Car.LISTED) NotNull<LocalDate> nonNull,
@By(_Car.LISTED) @Is(AtLeast.class) LocalDate oldestListDate,
Order<Car> sorts);
...
found = cars.listedRecently(NotNull.instance(),
LocalDate.now().minusDays(15),
Order.by(_Car.listed.desc()));
Repository methods can also accept NotNull constraints at
run time in the form of a Restriction on an Expression.
For example,
@Find
List<Car> searchAll(Restriction<Car> restrict, Order<Car> sorts);
...
found = cars.searchAll(Restrict.all(_Car.make.equalTo("Jakarta Motors"),
_Car.listed.notNull(),
_Car.listed.greaterThan(LocalDate.now().minusDays(20))),
Order.by(_Car.listed.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
Static MethodsMethods inherited from interface jakarta.data.constraint.Constraint
negate
-
Method Details
-
instance
Requires that the constraint target not have a
nullvalue. For example,found = cars.listedRecently(NotNull.instance(), LocalDate.now().minusDays(10));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Returns:
- a
NotNullconstraint.
-