Module jakarta.data

Interface NumericLiteral<N extends Number & Comparable<N>>

Type Parameters:
N - entity attribute type.
All Superinterfaces:
ComparableExpression<Object,N>, ComparableLiteral<N>, Expression<Object,N>, Literal<N>, NumericExpression<Object,N>

public interface NumericLiteral<N extends Number & Comparable<N>> extends ComparableLiteral<N>, NumericExpression<Object,N>

A literal for a numeric value.

Since:
1.1
  • Method Details

    • of

      static <N extends Number & Comparable<N>> NumericLiteral<N> of(Class<? extends N> type, N value)

      Creates a NumericLiteral that represents the given value.

      Type Parameters:
      N - entity attribute type.
      Parameters:
      value - an immutable numeric value. Must never be null.
      Returns:
      a NumericLiteral representing the value.
      Throws:
      NullPointerException - if the value is null.
    • of

      static NumericLiteral<Integer> of(int value)
      Create a NumericLiteral representing the given int.
    • of

      static NumericLiteral<Long> of(long value)
      Create a NumericLiteral representing the given long.
    • of

      static NumericLiteral<Float> of(float value)
      Create a NumericLiteral representing the given float.
    • of

      static NumericLiteral<Double> of(double value)
      Create a NumericLiteral representing the given double.
    • of

      static NumericLiteral<Byte> of(byte value)
      Create a NumericLiteral representing the given byte.
    • of

      static NumericLiteral<Short> of(short value)
      Create a NumericLiteral representing the given short.
    • of

      static NumericLiteral<BigInteger> of(BigInteger value)
      Create a NumericLiteral representing the given BigInteger.
    • of

      static NumericLiteral<BigDecimal> of(BigDecimal value)
      Create a NumericLiteral representing the given BigDecimal.
    • toString

      String toString()

      Returns a String representing the literal numeric value.

      For the following types, the String consists of the numeric value, followed by

      For values of type Integer, the String consists of the numeric value without any suffix.

      For all other types, the String begins with an opening curly brace and ends with a closing curly brace. Between the braces are 3 terms delimited by a space character. The first term is NumericLiteral. The second term is the fully qualified class name of the value's type. The third term is the toString() output of the value, enclosed in single quotes.

      For example, the output of NumericLiteral.of(BigDecimal.valueOf(123456789, 2)).toString() is

       1234567.89BD
       
      Specified by:
      toString in interface ComparableLiteral<N extends Number & Comparable<N>>
      Specified by:
      toString in interface Literal<N extends Number & Comparable<N>>
      Overrides:
      toString in class Object
      Returns:
      a String representing the literal numeric value.