Package org.apache.flink.types.variant
Interface Variant
-
- All Known Implementing Classes:
BinaryVariant
@PublicEvolving public interface VariantVariant represent a semi-structured data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classVariant.TypeThe type of variant.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Objectget()Get the scalar value of variant.<T> TgetAs()Get the scalar value of variant.booleangetBoolean()Get the scalar value of variant as boolean, if the variant type isVariant.Type.BOOLEAN.bytegetByte()Get the scalar value of variant as byte, if the variant type isVariant.Type.TINYINT.byte[]getBytes()Get the scalar value of variant as byte array, if the variant type isVariant.Type.BYTES.LocalDategetDate()Get the scalar value of variant as LocalDate, if the variant type isVariant.Type.DATE.LocalDateTimegetDateTime()Get the scalar value of variant as LocalDateTime, if the variant type isVariant.Type.TIMESTAMP.BigDecimalgetDecimal()Get the scalar value of variant as BigDecimal, if the variant type isVariant.Type.DECIMAL.doublegetDouble()Get the scalar value of variant as double, if the variant type isVariant.Type.DOUBLE.VariantgetElement(int index)Access value of the specified element of an array variant.VariantgetField(String fieldName)Access value of the specified field of an object variant.floatgetFloat()Get the scalar value of variant as float, if the variant type isVariant.Type.FLOAT.InstantgetInstant()Get the scalar value of variant as Instant, if the variant type isVariant.Type.TIMESTAMP.intgetInt()Get the scalar value of variant as int, if the variant type isVariant.Type.INT.longgetLong()Get the scalar value of variant as long, if the variant type isVariant.Type.BIGINT.shortgetShort()Get the scalar value of variant as short, if the variant type isVariant.Type.SMALLINT.StringgetString()Get the scalar value of variant as string, if the variant type isVariant.Type.STRING.Variant.TypegetType()Get the type of variant.booleanisArray()Returns true if this variant is an Array, false otherwise.booleanisNull()Check If this variant is null.booleanisObject()Returns true if this variant is an Object, false otherwise.booleanisPrimitive()Returns true if the variant is a primitive typed value, such as INT, DOUBLE, STRING, etc.static VariantBuildernewBuilder()StringtoJson()Parses the variant to json.
-
-
-
Method Detail
-
isPrimitive
boolean isPrimitive()
Returns true if the variant is a primitive typed value, such as INT, DOUBLE, STRING, etc.
-
isArray
boolean isArray()
Returns true if this variant is an Array, false otherwise.
-
isObject
boolean isObject()
Returns true if this variant is an Object, false otherwise.
-
isNull
boolean isNull()
Check If this variant is null.
-
getType
Variant.Type getType()
Get the type of variant.
-
getBoolean
boolean getBoolean() throws VariantTypeExceptionGet the scalar value of variant as boolean, if the variant type isVariant.Type.BOOLEAN.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.BOOLEAN.
-
getByte
byte getByte() throws VariantTypeExceptionGet the scalar value of variant as byte, if the variant type isVariant.Type.TINYINT.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.TINYINT.
-
getShort
short getShort() throws VariantTypeExceptionGet the scalar value of variant as short, if the variant type isVariant.Type.SMALLINT.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.SMALLINT.
-
getInt
int getInt() throws VariantTypeExceptionGet the scalar value of variant as int, if the variant type isVariant.Type.INT.- Throws:
VariantTypeException- if this variant is not a scalar value or is notVariant.Type.INT.
-
getLong
long getLong() throws VariantTypeExceptionGet the scalar value of variant as long, if the variant type isVariant.Type.BIGINT.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.BIGINT.
-
getFloat
float getFloat() throws VariantTypeExceptionGet the scalar value of variant as float, if the variant type isVariant.Type.FLOAT.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.FLOAT.
-
getDecimal
BigDecimal getDecimal() throws VariantTypeException
Get the scalar value of variant as BigDecimal, if the variant type isVariant.Type.DECIMAL.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.DECIMAL.
-
getDouble
double getDouble() throws VariantTypeExceptionGet the scalar value of variant as double, if the variant type isVariant.Type.DOUBLE.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.DOUBLE.
-
getString
String getString() throws VariantTypeException
Get the scalar value of variant as string, if the variant type isVariant.Type.STRING.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.STRING.
-
getDate
LocalDate getDate() throws VariantTypeException
Get the scalar value of variant as LocalDate, if the variant type isVariant.Type.DATE.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.DATE.
-
getDateTime
LocalDateTime getDateTime() throws VariantTypeException
Get the scalar value of variant as LocalDateTime, if the variant type isVariant.Type.TIMESTAMP.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.TIMESTAMP.
-
getInstant
Instant getInstant() throws VariantTypeException
Get the scalar value of variant as Instant, if the variant type isVariant.Type.TIMESTAMP.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.TIMESTAMP.
-
getBytes
byte[] getBytes() throws VariantTypeExceptionGet the scalar value of variant as byte array, if the variant type isVariant.Type.BYTES.- Throws:
VariantTypeException- If this variant is not a scalar value or is notVariant.Type.BYTES.
-
get
Object get() throws VariantTypeException
Get the scalar value of variant.- Throws:
VariantTypeException- If this variant is not a scalar value.
-
getAs
<T> T getAs() throws VariantTypeExceptionGet the scalar value of variant.- Throws:
VariantTypeException- If this variant is not a scalar value.
-
getElement
Variant getElement(int index) throws VariantTypeException
Access value of the specified element of an array variant. If index is out of range, null is returned.NOTE: if the element value has been explicitly set as
null(which is different from removal!), a variant that @isNull()returns true will be returned, not null.- Throws:
VariantTypeException- If this variant is not an array.
-
getField
Variant getField(String fieldName) throws VariantTypeException
Access value of the specified field of an object variant. If there is no field with the specified name, null is returned.NOTE: if the property value has been explicitly set as
null, a variant that @isNull()returns true will be returned, not null.- Throws:
VariantTypeException- If this variant is not an object.
-
toJson
String toJson()
Parses the variant to json.
-
newBuilder
static VariantBuilder newBuilder()
-
-