Module jakarta.data

Interface NumericExpression<T,N extends Number & Comparable<N>>

Type Parameters:
T - entity type.
N - expression type.
All Superinterfaces:
ComparableExpression<T,N>, Expression<T,N>
All Known Subinterfaces:
NumericAttribute<T,N>, NumericCast<T,N>, NumericFunctionExpression<T,N>, NumericLiteral<N>, NumericOperatorExpression<T,N>, NumericPath<T,U,N>

public interface NumericExpression<T,N extends Number & Comparable<N>> extends ComparableExpression<T,N>

An expression that evaluates to a numeric typed value.

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

Since:
1.1
  • Method Details

    • abs

      default NumericExpression<T,N> abs()

      Represents the absolute value function applied to the value to which the current expression evaluates.

      Example:

      
           within2YearsOf2024 = cars.search(make,
                                            model,
                                            _Car.year.minus(2024).abs().lessThanEqual(2));
       
      Returns:
      an expression for the function that computes the absolute value.
    • negated

      default NumericExpression<T,N> negated()

      Represents the sign negation function applied to the value to which the current expression evaluates. The sign negation function reverse the sign (positive to negative or negative to positive) of the value. It has no effect on the value 0.

      Example:

      
           atLeast2YearsBeyondOriginalModelYear = cars.search(
                   make,
                   model,
                   _Car.firstModelYear.minus(_Car.year).negated().greaterThanEqual(2));
       
      Returns:
      an expression for the function that computes negation of value.
    • plus

      default NumericExpression<T,N> plus(N value)

      Represents the addition function that computes the sum of the value to which the current expression evaluates plus the given value.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.price.plus(fees).lessThan(30000));
       
      Parameters:
      value - the value to add. Must not be null.
      Returns:
      an expression for the function that computes the sum.
      Throws:
      NullPointerException - if the supplied value is null.
    • minus

      default NumericExpression<T,N> minus(N value)

      Represents the subtraction function that computes the difference of the value to which the current expression evaluates minus the given value.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.price.minus(discount).lessThanEqual(25000));
       
      Parameters:
      value - the value to subtract. Must not be null.
      Returns:
      an expression for the function that computes the difference.
      Throws:
      NullPointerException - if the supplied value is null.
    • subtractedFrom

      default NumericExpression<T,N> subtractedFrom(N value)

      Represents the subtraction function that computes the difference of the given value minus the value to which the current expression evaluates.

      Example:

      
           found = cars.search(
                   make,
                   model,
                   _Car.price.asDouble().times(_Car.discountRate.subtractedFrom(1.0))
                           .lessThanEqual(33000.0));
       
      Parameters:
      value - the value to subtract from. Must not be null.
      Returns:
      an expression for the function that computes the difference.
      Throws:
      NullPointerException - if the supplied value is null.
    • dividedInto

      default NumericExpression<T,N> dividedInto(N value)

      Represents the division function that computes the quotient of the given value divided by the value to which the current expression evaluates.

      Parameters:
      value - the value to divide into. Must not be null.
      Returns:
      an expression for the function that computes the quotient.
      Throws:
      NullPointerException - if the supplied value is null.
    • times

      default NumericExpression<T,N> times(N factor)

      Represents the multiplication function that computes the product of the value to which the current expression evaluates times the given factor.

      Example:

      
           found = cars.search(
                   make,
                   model,
                   _Car.price.asDouble().times(1.0 + taxRate).lessThan(35000.0));
       
      Parameters:
      factor - the value times which to multiply. Must not be null.
      Returns:
      an expression for the function that computes the product.
      Throws:
      NullPointerException - if the supplied factor value is null.
    • dividedBy

      default NumericExpression<T,N> dividedBy(N divisor)

      Represents the division function that computes the quotient of the value to which the current expression evaluates divided by the given divisor value.

      Example:

      
           found = cars.search(
                   make,
                   model,
                   _Car.price.asDouble().dividedBy(1.0 + discountRate).lessThan(27000.0));
       
      Parameters:
      divisor - the value by which to divide. Must not be 0 or null.
      Returns:
      an expression for the function that computes the quotient.
      Throws:
      NullPointerException - if the supplied divisor value is null.
    • plus

      default NumericExpression<T,N> plus(NumericExpression<? super T,N> expression)

      Represents the addition function that computes the sum of the values to which the current expression and the given expression evaluate.

      Example:

      
           found = cars.search(
                   make,
                   model,
                   _Car.price.plus(_Car.price.times(percentTax).dividedBy(100))
                             .lessThan(32000));
       
      Parameters:
      expression - expression that evaluates to the value to add. Must not be null.
      Returns:
      an expression for the function that computes the sum.
      Throws:
      NullPointerException - if the supplied value is null.
    • minus

      default NumericExpression<T,N> minus(NumericExpression<? super T,N> expression)

      Represents the subtraction function that computes the difference of the value to which the current expression evaluates minus the value to which the given expression evaluates.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.year.minus(_Car.firstModelYear).greaterThan(1));
       
      Parameters:
      expression - expression that evaluates to the value to subtract. Must not be null.
      Returns:
      an expression for the function that computes the difference.
      Throws:
      NullPointerException - if the supplied expression is null.
    • times

      default NumericExpression<T,N> times(NumericExpression<? super T,N> factorExpression)

      Represents the multiplication function that computes the product of the values to which the current expression and the given factor expression evaluate.

      Example:

      
           discountedMoreThan2000 = cars.search(
                   make,
                   model,
                   _Car.price.asDouble().times(_Car.discountRate).greaterThan(2000.0));
       
      Parameters:
      factorExpression - expression that evaluates to the value by which to multiply. Must not be null.
      Returns:
      an expression for the function that computes the product.
      Throws:
      NullPointerException - if the supplied factor expression is null.
    • dividedBy

      default NumericExpression<T,N> dividedBy(NumericExpression<? super T,N> divisorExpression)

      Represents the division function that computes the quotient of the value to which the current expression evaluates divided by the value to which the divisor expression evaluates.

      Example:

      
           pricedUnder95PercentWithRebate = cars.search(
                   make,
                   model,
                   _Car.price.minus(rebate).times(100).dividedBy(_Car.price).lessThan(95));
       
      Parameters:
      divisorExpression - expression that evaluates to the value by which to divide. Must not be null.
      Returns:
      an expression for the function that computes the quotient.
      Throws:
      NullPointerException - if the supplied divisor expression is null.
    • asLong

      default NumericExpression<T,Long> asLong()

      Represents the cast function that converts the value to which the current expression evaluates to Long.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.price.asLong().lessThan(36000L));
       
      Returns:
      an expression for the function that casts to Long.
    • asDouble

      default NumericExpression<T,Double> asDouble()

      Represents the cast function that converts the value to which the current expression evaluates to Double.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.price.asDouble().lessThan(34000.0));
       
      Returns:
      an expression for the function that casts to Double.
    • asBigInteger

      default NumericExpression<T,BigInteger> asBigInteger()

      Represents the cast function that converts the value to which the current expression evaluates to BigInteger.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.price.asBigInteger().lessThan(BigInteger.valueOf(50000L)));
       
      Returns:
      an expression for the function that casts to BigInteger.
    • asBigDecimal

      default NumericExpression<T,BigDecimal> asBigDecimal()

      Represents the cast function that converts the value to which the current expression evaluates to BigDecimal.

      Example:

      
           found = cars.search(make,
                               model,
                               _Car.price.asBigDecimal().lessThan(BigDecimal.valueOf(45000L)));
       
      Returns:
      an expression for the function that casts to BigDecimal.