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

    • asc

      @Nonnull default Sort<T> asc()
      Obtain a request for an ascending Sort based on the value to which this expression computes.
      Returns:
      a request for an ascending sort.
    • between

      @Nonnull default Restriction<T> between(@Nonnull V min, @Nonnull 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

      @Nonnull default <U extends ComparableExpression<? super T, V>> Restriction<T> between(@Nonnull U minExpression, @Nonnull 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.
    • desc

      @Nonnull default Sort<T> desc()
      Obtain a request for a descending Sort based on the value to which this expression computes.
      Returns:
      a request for a descending sort.
    • greaterThan

      @Nonnull default Restriction<T> greaterThan(@Nonnull 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

      @Nonnull default Restriction<T> greaterThan(@Nonnull 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

      @Nonnull default Restriction<T> greaterThanEqual(@Nonnull 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

      @Nonnull default Restriction<T> greaterThanEqual(@Nonnull 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

      @Nonnull default Restriction<T> lessThan(@Nonnull 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

      @Nonnull default Restriction<T> lessThan(@Nonnull 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

      @Nonnull default Restriction<T> lessThanEqual(@Nonnull 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

      @Nonnull default Restriction<T> lessThanEqual(@Nonnull 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

      @Nonnull default Restriction<T> notBetween(@Nonnull V min, @Nonnull 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

      @Nonnull default <U extends ComparableExpression<? super T, V>> Restriction<T> notBetween(@Nonnull U minExpression, @Nonnull 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.