Interface Literal<T>
-
- Type Parameters:
T
- The Java type of the value wrapped by aLiteral
- All Superinterfaces:
java.io.Serializable
public interface Literal<T> extends java.io.Serializable
Represents a literal fixed value in an expression predicate
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Comparator<T>
comparator()
Return aComparator
for values.static Literal<java.lang.Boolean>
of(boolean value)
static Literal<java.nio.ByteBuffer>
of(byte[] value)
static Literal<java.lang.Double>
of(double value)
static Literal<java.lang.Float>
of(float value)
static Literal<java.lang.Integer>
of(int value)
static Literal<java.lang.Long>
of(long value)
static Literal<java.lang.CharSequence>
of(java.lang.CharSequence value)
static Literal<java.math.BigDecimal>
of(java.math.BigDecimal value)
static Literal<java.nio.ByteBuffer>
of(java.nio.ByteBuffer value)
static Literal<java.util.UUID>
of(java.util.UUID value)
<X> Literal<X>
to(Type type)
Converts this literal to a literal of the given type.default java.nio.ByteBuffer
toByteBuffer()
Serializes the value wrapped by this literal to binary using the single-value serialization format described in the Iceberg table specification.T
value()
Returns the value wrapped by this literal.
-
-
-
Method Detail
-
of
static Literal<java.lang.Boolean> of(boolean value)
-
of
static Literal<java.lang.Integer> of(int value)
-
of
static Literal<java.lang.Long> of(long value)
-
of
static Literal<java.lang.Float> of(float value)
-
of
static Literal<java.lang.Double> of(double value)
-
of
static Literal<java.lang.CharSequence> of(java.lang.CharSequence value)
-
of
static Literal<java.util.UUID> of(java.util.UUID value)
-
of
static Literal<java.nio.ByteBuffer> of(byte[] value)
-
of
static Literal<java.nio.ByteBuffer> of(java.nio.ByteBuffer value)
-
of
static Literal<java.math.BigDecimal> of(java.math.BigDecimal value)
-
value
T value()
Returns the value wrapped by this literal.
-
to
<X> Literal<X> to(Type type)
Converts this literal to a literal of the given type.When a predicate is bound to a concrete data column, literals are converted to match the bound column's type. This conversion process is more narrow than a cast and is only intended for cases where substituting one type is a common mistake (e.g. 34 instead of 34L) or where this API avoids requiring a concrete class (e.g., dates).
If conversion to a target type is not supported, this method returns null.
This method may return
Literals.aboveMax()
orLiterals.belowMin()
when the target type is not as wide as the original type. These values indicate that the containing predicate can be simplified. For example, Integer.MAX_VALUE+1 converted to an int will result inaboveMax
and can simplify a < Integer.MAX_VALUE+1 toExpressions.alwaysTrue()
- Type Parameters:
X
- The Java type of value the new literal contains- Parameters:
type
- A primitiveType
- Returns:
- A literal of the given type or null if conversion was not valid
-
comparator
java.util.Comparator<T> comparator()
Return aComparator
for values.- Returns:
- a comparator for T objects
-
toByteBuffer
default java.nio.ByteBuffer toByteBuffer()
Serializes the value wrapped by this literal to binary using the single-value serialization format described in the Iceberg table specification.- Returns:
- a ByteBuffer that contains the serialized literal value.
-
-