Package dev.vortex.api.proto
Class Scalars
java.lang.Object
dev.vortex.api.proto.Scalars
Factory class for creating Vortex scalar values with their associated data types.
This class provides static factory methods to create ScalarProtos.Scalar
instances
for all supported Vortex data types. Each scalar consists of a value and its corresponding
data type definition. The class supports both nullable and non-nullable variants for most types.
Factory methods follow a consistent naming pattern:
typeName(value)
- Creates a non-nullable scalar with the given valuenullTypeName()
- Creates a nullable scalar with a null value
Example usage:
// Create a non-nullable integer
ScalarProtos.Scalar intScalar = Scalars.int32(42);
// Create a nullable string with null value
ScalarProtos.Scalar nullString = Scalars.nullString();
// Create a string with value
ScalarProtos.Scalar stringScalar = Scalars.string("hello");
-
Method Summary
Modifier and TypeMethodDescriptionstatic ScalarProtos.Scalar
bool
(boolean value) Creates a non-nullable boolean scalar with the specified value.static ScalarProtos.Scalar
bytes
(byte[] value) static ScalarProtos.Scalar
dateDays
(int value) static ScalarProtos.Scalar
dateMillis
(long value) static ScalarProtos.Scalar
decimal
(BigDecimal decimal, int precision, int scale) Creates a non-nullable decimal scalar with the specified value, precision, and scale.static ScalarProtos.Scalar
float32
(float value) static ScalarProtos.Scalar
float64
(double value) static ScalarProtos.Scalar
int16
(short value) static ScalarProtos.Scalar
int32
(int value) Creates a non-nullable 32-bit integer scalar with the specified value.static ScalarProtos.Scalar
int64
(long value) static ScalarProtos.Scalar
int8
(byte value) static ScalarProtos.Scalar
nullBool()
Creates a nullable boolean scalar with a null value.static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
nullDecimal
(int precision, int scale) static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
nullInt8()
static ScalarProtos.Scalar
nullNull()
Creates a null scalar value.static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
static ScalarProtos.Scalar
nullTimestampMicros
(Optional<String> timeZone) static ScalarProtos.Scalar
nullTimestampMillis
(Optional<String> timeZone) static ScalarProtos.Scalar
nullTimestampNanos
(Optional<String> timeZone) static ScalarProtos.Scalar
Creates a non-nullable string scalar with the specified value.static ScalarProtos.Scalar
timeMicros
(long value) static ScalarProtos.Scalar
timeMillis
(int value) static ScalarProtos.Scalar
timeNanos
(long value) static ScalarProtos.Scalar
timeSeconds
(int value) static ScalarProtos.Scalar
timestampMicros
(long value, Optional<String> timeZone) static ScalarProtos.Scalar
timestampMillis
(long value, Optional<String> timeZone) Creates a non-nullable timestamp scalar with millisecond precision.static ScalarProtos.Scalar
timestampNanos
(long value, Optional<String> timeZone)
-
Method Details
-
nullNull
Creates a null scalar value.This represents a scalar that is explicitly null with null data type.
- Returns:
- a
ScalarProtos.Scalar
representing a null value
-
bool
Creates a non-nullable boolean scalar with the specified value.- Parameters:
value
- the boolean value- Returns:
- a
ScalarProtos.Scalar
containing the boolean value
-
nullBool
Creates a nullable boolean scalar with a null value.- Returns:
- a
ScalarProtos.Scalar
representing a null boolean
-
int8
-
nullInt8
-
int16
-
nullInt16
-
int32
Creates a non-nullable 32-bit integer scalar with the specified value.- Parameters:
value
- the integer value- Returns:
- a
ScalarProtos.Scalar
containing the 32-bit integer value
-
nullInt32
-
int64
-
nullInt64
-
float32
-
nullFloat32
-
float64
-
nullFloat64
-
string
Creates a non-nullable string scalar with the specified value.- Parameters:
value
- the string value- Returns:
- a
ScalarProtos.Scalar
containing the string value
-
nullString
-
decimal
Creates a non-nullable decimal scalar with the specified value, precision, and scale.The decimal value is converted to little-endian byte representation for storage.
- Parameters:
decimal
- the decimal value as aBigDecimal
precision
- the total number of digits in the decimalscale
- the number of digits after the decimal point- Returns:
- a
ScalarProtos.Scalar
containing the decimal value
-
nullDecimal
-
bytes
-
nullBytes
-
dateDays
-
nullDateDays
-
dateMillis
-
nullDateMillis
-
timeSeconds
-
nullTimeSeconds
-
timeMillis
-
nullTimeMillis
-
timeMicros
-
nullTimeMicros
-
timeNanos
-
nullTimeNanos
-
timestampMillis
Creates a non-nullable timestamp scalar with millisecond precision.The timestamp represents the number of milliseconds since Unix epoch (1970-01-01 00:00:00 UTC), optionally adjusted for the specified time zone.
- Parameters:
value
- the timestamp value in milliseconds since Unix epochtimeZone
- optional time zone identifier (e.g., "UTC", "America/New_York")- Returns:
- a
ScalarProtos.Scalar
containing the timestamp value
-
nullTimestampMillis
-
timestampMicros
-
nullTimestampMicros
-
timestampNanos
-
nullTimestampNanos
-