- All Known Implementing Classes:
ArrayValue,BooleanValue,DateValue,DurationValue,NullValue,NumberValue,StringValue,StructValue,TimestampValue,TimeValue
public sealed interface Value
permits StringValue, NumberValue, BooleanValue, NullValue, StructValue, ArrayValue, DateValue, TimeValue, TimestampValue, DurationValue
A runtime scalar value produced or consumed during query execution.
The sealed hierarchy maps directly onto the type lattice in
ScalarType:
StringValue—STRINGNumberValue—NUMBERBooleanValue—BOOLEANNullValue— absent value, compatible with all typesStructValue— a nested object; reportsScalarType.ANYArrayValue— a nested array; reportsScalarType.ANYDateValue—DATE(aLocalDate)TimeValue—TIME(aLocalTime)TimestampValue—TIMESTAMP(a UTCInstant)DurationValue—DURATION(aDuration)
Pattern matching over the sealed subtypes is the preferred way to dispatch on value kind:
String display = switch (value) {
case StringValue s -> s.value();
case NumberValue n -> n.value().toPlainString();
case BooleanValue b -> String.valueOf(b.value());
case NullValue n -> "NULL";
default -> value.asDisplayString();
};
A switch that names every subtype needs no default and will not compile
once a new one is added — which is the point of sealing the hierarchy.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a human-readable display string for this value, suitable for output formatting.booleanisNull()Returnstrueif this value is null (absent).type()Returns theScalarTypethat describes this value's kind.
-
Method Details
-
isNull
boolean isNull()Returnstrueif this value is null (absent).- Returns:
- whether this is a
NullValue
-
type
ScalarType type()- Returns:
- the scalar type
-
asDisplayString
String asDisplayString()Returns a human-readable display string for this value, suitable for output formatting.NullValuereturns"NULL".- Returns:
- display string; never
null
-