Module jakarta.data

Interface ComparableExpression<T,V extends Comparable<?>>

Type Parameters:
T - entity type.
V - expression type.
All Superinterfaces:
Expression<T,V>
All Known Subinterfaces:
BooleanAttribute<T>, BooleanExpression<T>, BooleanLiteral, BooleanPath<T,U>, ComparableAttribute<T,V>, ComparableLiteral<V>, ComparablePath<T,U,C>, CurrentDate<T>, CurrentDateTime<T>, CurrentTime<T>, NumericAttribute<T,N>, NumericCast<T,N>, NumericExpression<T,N>, NumericFunctionExpression<T,N>, NumericLiteral<N>, NumericOperatorExpression<T,N>, NumericPath<T,U,N>, StringLiteral, TemporalAttribute<T,V>, TemporalExpression<T,V>, TemporalLiteral<V>, TemporalPath<T,U,V>, TextAttribute<T>, TextExpression<T>, TextFunctionExpression<T>, TextPath<T,U>
All Known Implementing Classes:
TextAttributeRecord

public interface ComparableExpression<T,V extends Comparable<?>> extends Expression<T,V>

An expression that evaluates to a comparable result that can be sorted.

A more specific subtype, such as BooleanExpression, NumericExpression, TemporalExpression, or TextExpression, should be used instead wherever it is possible.

The entity and static metamodel for the code examples within this class are shown in the Attribute Javadoc.

Since:
1.1
  • Method Details

    • between

      default Restriction<T> between(V min, V max)

      Obtains a Restriction that requires that this expression evaluate to a value falling within the range between (and inclusive of) the specified values.

      Example:

      
           found = cars.search(make, model, _Car.year.between(2022, 2025));
       
      Parameters:
      min - the lower bound on the range. Must not be null.
      max - the upper bound on the range. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the value is null.
    • between

      default <U extends ComparableExpression<? super T, V>> Restriction<T> between(U minExpression, U maxExpression)

      Obtains a Restriction that requires that this expression evaluate to a value falling within the range between (and inclusive of) the values to which the given expressions evaluate.

      Example:

      
           preOwnedInRangeOfModelYears = cars.search(
               make,
               model,
               _Car.year.between(_Car.firstModelYear.plus(2),
                                 _Car.firstModelYear.plus(5)));
       
      Parameters:
      minExpression - expression that evaluates to the lower bound on the range. Must not be null.
      maxExpression - expression that evaluates to the upper bound on the range. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the expression is null.
    • greaterThan

      default Restriction<T> greaterThan(V value)

      Obtains a Restriction that requires that this expression evaluate to a value greater than the given value.

      Example:

      
           found = cars.search(make, model, _Car.price.greaterThan(25000));
       
      Parameters:
      value - value against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the value is null.
    • greaterThan

      default Restriction<T> greaterThan(ComparableExpression<? super T,V> expression)

      Obtains a Restriction that requires that this expression evaluate to a value greater than the value to which the given expression evaluates.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.year.greaterThan(_Car.firstModelYear));
       
      Parameters:
      expression - expression against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the expression is null.
    • greaterThanEqual

      default Restriction<T> greaterThanEqual(V value)

      Obtains a Restriction that requires that this expression evaluate to a value greater than or equal to the given value.

      Example:

      
           atLeast2024 = cars.search(make, model, _Car.year.greaterThanEqual(2024));
       
      Parameters:
      value - value against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the value is null.
    • greaterThanEqual

      default Restriction<T> greaterThanEqual(ComparableExpression<? super T,V> expression)

      Obtains a Restriction that requires that this expression evaluate to a value greater than or equal to the value to which the given expression evaluates.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.year.greaterThanEqual(_Car.firstModelYear.plus(2)));
       
      Parameters:
      expression - expression against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the expression is null.
    • lessThan

      default Restriction<T> lessThan(V value)

      Obtains a Restriction that requires that this expression evaluate to a value smaller than the given value.

      Example:

      
           found = cars.search(make, model, _Car.price.lessThan(35000));
       
      Parameters:
      value - value against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the value is null.
    • lessThan

      default Restriction<T> lessThan(ComparableExpression<? super T,V> expression)

      Obtains a Restriction that requires that this expression evaluate to a value smaller than the value to which the given expression evaluates.

      Example:

      
           listedBeforeToday = cars.search(make,
                                           model,
                                           _Car.listed.lessThan(CurrentDate.now()));
       
      Parameters:
      expression - expression against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the expression is null.
    • lessThanEqual

      default Restriction<T> lessThanEqual(V value)

      Obtains a Restriction that requires that this expression evaluate to a value less than or equal to the given value.

      Example:

      
           found = cars.search(make, model, _Car.price.lessThanEqual(25000));
       
      Parameters:
      value - value against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the value is null.
    • lessThanEqual

      default Restriction<T> lessThanEqual(ComparableExpression<? super T,V> expression)

      Obtains a Restriction that requires that this expression evaluate to a value less than or equal to the value to which the given expression evaluates.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.firstModelYear.lessThanEqual(_Car.year.minus(2)));
       
      Parameters:
      expression - expression against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the expression is null.
    • notBetween

      default Restriction<T> notBetween(V min, V max)

      Obtains a Restriction that requires that this expression evaluate to a value falling outside the range between given values.

      Example:

      
           found = cars.search(make, model, _Car.year.notBetween(2021, 2023));
       
      Parameters:
      min - the lower bound on the range. Must not be null.
      max - the upper bound on the range. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the value is null.
    • notBetween

      default <U extends ComparableExpression<? super T, V>> Restriction<T> notBetween(U minExpression, U maxExpression)

      Obtains a Restriction that requires that this expression evaluate to a value falling outside the range between the values to which the given expressions evaluate.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.year.notBetween(_Car.firstModelYear,
                                                    _Car.firstModelYear.plus(2)));
       
      Parameters:
      minExpression - expression that evaluates to the lower bound on the range. Must not be null.
      maxExpression - expression that evaluates to the lower bound on the range. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the expression is null.