Module jakarta.data

Interface NotIn<V>

Type Parameters:
V - type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.
All Superinterfaces:
Constraint<V>

public interface NotIn<V> extends Constraint<V>

A constraint that requires inequality with every 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 NotIn. For example,


 @Find
 List<Car> excludingManufacturers(@By(_Car.MAKE) NotIn<String> excluded);
 ...

 found = cars.excludingManufacturers(NotIn.values("Leakoil Motors",
                                                  "Stallmore Motors"));
 

Repository methods can also accept NotIn 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(_Car.make.notIn("Leakoil Motors",
                                        "Stallmore Motors"),
                        Order.by(_Car.make.asc(),
                                 _Car.model.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 Type
    Method
    Description
    Expressions that evaluate to the values against which the constraint target is compared.
    static <V> NotIn<V>
    expressions(Expression<?,V>... expressions)
    Requires that the constraint target not equal any of the values to which the given expressions evaluate.
    static <V> NotIn<V>
    expressions(List<Expression<?,V>> expressions)
    Requires that the constraint target not equal any of the values to which the given expressions evaluate.
    static <V> NotIn<V>
    values(Collection<V> values)
    Requires that the constraint target not equal any of the given values.
    static <V> NotIn<V>
    values(V... values)
    Requires that the constraint target not equal any of the given values.

    Methods inherited from interface jakarta.data.constraint.Constraint

    negate
  • Method Details

    • values

      @SafeVarargs static <V> NotIn<V> values(V... values)

      Requires that the constraint target not equal any of the given values. For example,

      
           found = cars.excludingManufacturers(NotIn.values("Stallmore Motors",
                                                            "Knockhard 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:
      a NotIn constraint.
      Throws:
      IllegalArgumentException - if the values array is empty.
      NullPointerException - if the values array or any value within it is null.
    • values

      static <V> NotIn<V> values(Collection<V> values)

      Requires that the constraint target not equal any of the given values. For example,

      
           found = cars.excludingManufacturers(NotIn.values(Set.of("Leakoil Motors",
                                                                   "Knockhard 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:
      a NotIn constraint.
      Throws:
      IllegalArgumentException - if the collection of values is empty.
      NullPointerException - if the collection of values or any value within it is null.
    • expressions

      static <V> NotIn<V> expressions(List<Expression<?,V>> expressions)

      Requires that the constraint target not equal any of the values to which the given expressions evaluate. For example,

      
           found = cars.excludingManufacturers(
                       NotIn.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:
      a NotIn constraint.
      Throws:
      IllegalArgumentException - if the list of expressions is empty.
      NullPointerException - if the list of expressions or any value within it is null.
    • expressions

      @SafeVarargs static <V> NotIn<V> expressions(Expression<?,V>... expressions)

      Requires that the constraint target not equal any of the values to which the given expressions evaluate. For example,

      
           found = cars.excludingManufacturers(
                       NotIn.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:
      a NotIn constraint.
      Throws:
      IllegalArgumentException - if the array of expressions is empty.
      NullPointerException - if the array of expressions or any value within it is null.
    • 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 Collection that was supplied to the static method that created the NotIn constraint.

      Returns:
      expressions representing the values.