- 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 equality with a member of a collection.
A parameter-based repository method can impose a constraint on an
entity attribute by defining a method parameter that is of type In.
For example,
@Find
List<Car> manufacturedByAnyOf(@By(_Car.MAKE) In<String> manufactures);
...
found = cars.manufacturedByAnyOf(In.values("Jakarta Motors",
"JEE Motors"));
Repository methods can also accept In constraints at runtime
in the form of a Restriction on an Expression. For example,
@Find
List<Car> searchAll(Restriction<Car> restrict, Order<Car> sorts);
...
found = cars.searchAll(_Car.make.in("Jakarta Motors",
"JEE Motors"),
Order.by(_Car.model.asc(),
_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 TypeMethodDescriptionList<Expression<?, V>> Expressions that evaluate to the values against which the constraint target is compared.static <V> In<V> expressions(Expression<?, V>... expressions) Requires that the constraint target equal one of the values to which the givenexpressionsevaluate.static <V> In<V> expressions(List<Expression<?, V>> expressions) Requires that the constraint target equal one of the values to which the givenexpressionsevaluate.static <V> In<V> values(Collection<V> values) Requires that the constraint target equal one of the givenvalues.static <V> In<V> values(V... values) Requires that the constraint target equal one of the givenvalues.Methods inherited from interface jakarta.data.constraint.Constraint
negate
-
Method Details
-
values
Requires that the constraint target equal one of the given
values. For example,found = cars.manufacturedByAnyOf(In.values("Jakarta Motors", "JEE Motors"));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
values- values against which the constraint target is compared.- Returns:
- an
Inconstraint. - Throws:
IllegalArgumentException- if the values array is empty.NullPointerException- if the values array or any value within it isnull.
-
values
Requires that the constraint target equal one of the given
values. For example,found = cars.manufacturedByAnyOf(In.values(Set.of("Jakarta Motors", "JEE Motors")));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
values- values against which the constraint target is compared.- Returns:
- an
Inconstraint. - Throws:
IllegalArgumentException- if the collection of values is empty.NullPointerException- if the collection of values or any value within it isnull.
-
expressions
Requires that the constraint target equal one of the values to which the given
expressionsevaluate. For example,found = cars.manufacturedByAnyOf( In.expressions(List.of(_Car.model.left(_Car.make.length()), _Car.model.right(_Car.make.length()))));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
expressions- expressions that evaluate to the values against which the constraint target is compared.- Returns:
- an
Inconstraint. - Throws:
IllegalArgumentException- if the list of expressions is empty.NullPointerException- if the list of expressions or any value within it isnull.
-
expressions
Requires that the constraint target equal one of the values to which the given
expressionsevaluate. For example,found = cars.manufacturedByAnyOf( In.expressions(_Car.model.left(_Car.make.length()), _Car.model.right(_Car.make.length())));- Type Parameters:
V- type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.- Parameters:
expressions- expressions that evaluate to the values against which the constraint target is compared.- Returns:
- an
Inconstraint. - Throws:
IllegalArgumentException- if the array of expressions is empty.NullPointerException- if the array of expressions or any value within it isnull.
-
expressions
List<Expression<?,V>> expressions()Expressions that evaluate to the values against which the constraint target is compared. The order of the list of expressions matches the order of the array or the iteration order of the
Collectionthat was supplied to the static method that created theInconstraint.- Returns:
- expressions representing the values.
-