Module jakarta.data

Interface NotBetween<V extends Comparable<?>>

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 NotBetween<V extends Comparable<?>> extends Constraint<V>

A constraint that excludes values within a range.

A parameter-based repository method can impose a constraint on an entity attribute by defining a method parameter that is of type NotBetween and is of the same type or a subtype of the entity attribute. For example,


 @Find
 List<Car> byModelYear(@By(_Car.YEAR) NotBetween<Integer> yearsToExclude);

 ...

 found = cars.byModelYear(NotBetween.bounds(2020, 2022));
 

Repository methods can also accept NotBetween 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.notBetween(2019, 2021),
                        Order.by(_Car.year.desc(),
                                 _Car.price.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

    Modifier and Type
    Method
    Description
    static <V extends Comparable<?>>
    NotBetween<V>
    Requires that the constraint target evaluates to a value that is less than the value to which the given lower expression evaluates or greater than the value to which the given upper expression evaluates.
    static <V extends Comparable<?>>
    NotBetween<V>
    bounds(ComparableExpression<?,V> lower, V upper)
    Requires that the constraint target evaluates to a value that is less than the value to which the given lower expression evaluates or greater than the given upper bound.
    static <V extends Comparable<?>>
    NotBetween<V>
    bounds(V lower, ComparableExpression<?,V> upper)
    Requires that the constraint target evaluates to a value that is less than the given lower bound or greater than the value to which the given upper expression evaluates.
    static <V extends Comparable<?>>
    NotBetween<V>
    bounds(V lower, V upper)
    Requires that the constraint target evaluates to a value that is less than the given lower bound or greater than the given upper bound.
    An expression that evaluates to the minimum value excluded for the constraint target.
    An expression that evaluates to the maximum value excluded for the constraint target.

    Methods inherited from interface jakarta.data.constraint.Constraint

    negate
  • Method Details

    • bounds

      static <V extends Comparable<?>> NotBetween<V> bounds(V lower, V upper)

      Requires that the constraint target evaluates to a value that is less than the given lower bound or greater than the given upper bound. For example,

      
           found = cars.byModelYear(NotBetween.bounds(2022, 2024));
       
      Type Parameters:
      V - type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.
      Parameters:
      lower - the lower bound of the range to exclude.
      upper - the upper bound of the range to exclude.
      Returns:
      a NotBetween constraint.
      Throws:
      NullPointerException - if the lower or upper bound is null.
    • bounds

      static <V extends Comparable<?>> NotBetween<V> bounds(V lower, ComparableExpression<?,V> upper)

      Requires that the constraint target evaluates to a value that is less than the given lower bound or greater than the value to which the given upper expression evaluates. For example,

      
           found = cars.byModelYear(NotBetween.bounds(2015,
                                                      _Car.firstModelYear.plus(5)));
       
      Type Parameters:
      V - type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.
      Parameters:
      lower - the lower bound of the range to exclude.
      upper - an expression that evaluates to the upper bound of the range to exclude.
      Returns:
      a NotBetween constraint.
      Throws:
      NullPointerException - if lower or upper is null.
    • bounds

      static <V extends Comparable<?>> NotBetween<V> bounds(ComparableExpression<?,V> lower, V upper)

      Requires that the constraint target evaluates to a value that is less than the value to which the given lower expression evaluates or greater than the given upper bound. For example,

      
           found = cars.byModelYear(NotBetween.bounds(_Car.firstModelYear, 2022));
       
      Type Parameters:
      V - type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.
      Parameters:
      lower - an expression that evaluates to the lower bound of the range to exclude.
      upper - the upper bound of the range to exclude.
      Returns:
      a NotBetween constraint.
      Throws:
      NullPointerException - if lower or upper is null.
    • bounds

      static <V extends Comparable<?>> NotBetween<V> bounds(ComparableExpression<?,V> lower, ComparableExpression<?,V> upper)

      Requires that the constraint target evaluates to a value that is less than the value to which the given lower expression evaluates or greater than the value to which the given upper expression evaluates. For example,

      
           found = cars.byModelYear(NotBetween.bounds(_Car.firstModelYear,
                                                      _Car.firstModelYear.plus(2)));
       
      Type Parameters:
      V - type of the entity attribute or a subtype or primitive wrapper type for the entity attribute.
      Parameters:
      lower - an expression that evaluates to the lower bound of the range to exclude.
      upper - an expression that evaluates to the upper bound of the range to exclude.
      Returns:
      a NotBetween constraint.
      Throws:
      NullPointerException - if lower or upper is null.
    • lowerBound

      ComparableExpression<?,V> lowerBound()

      An expression that evaluates to the minimum value excluded for the constraint target.

      Returns:
      an expression representing the minimum value excluded.
    • upperBound

      ComparableExpression<?,V> upperBound()

      An expression that evaluates to the maximum value excluded for the constraint target.

      Returns:
      an expression representing the maximum value excluded.