Class Variant
java.lang.Object
io.confluent.kafka.schemaregistry.type.Variant
This Variant class holds the Variant-encoded value and metadata binary values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA field in a Variant object.static enumThe value type of Variant value. -
Constructor Summary
ConstructorsConstructorDescriptionVariant(byte[] value, byte[] metadata) Variant(byte[] value, int valuePos, int valueLength, byte[] metadata, int metadataPos, int metadataLength) Variant(ByteBuffer value, ByteBuffer metadata) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbytegetByte()doublegetElementAtIndex(int index) Returns the array element Variant value at the `index` slot.getFieldAtIndex(int idx) Returns the field at index idx, lexicographically ordered.getFieldByKey(String key) Returns the object field Variant value whose key is equal to `key`.floatgetFloat()intgetInt()longgetLong()shortgetShort()getType()getUUID()intint
-
Constructor Details
-
Variant
public Variant(byte[] value, byte[] metadata) -
Variant
public Variant(byte[] value, int valuePos, int valueLength, byte[] metadata, int metadataPos, int metadataLength) -
Variant
-
-
Method Details
-
getValueBuffer
-
getMetadataBuffer
-
getBoolean
public boolean getBoolean()- Returns:
- the boolean value
-
getByte
public byte getByte()- Returns:
- the byte value
-
getShort
public short getShort()- Returns:
- the short value
-
getInt
public int getInt()- Returns:
- the int value
-
getLong
public long getLong()- Returns:
- the long value
-
getDouble
public double getDouble()- Returns:
- the double value
-
getDecimal
- Returns:
- the decimal value
-
getFloat
public float getFloat()- Returns:
- the float value
-
getBinary
- Returns:
- the binary value
-
getUUID
- Returns:
- the UUID value
-
getString
- Returns:
- the string value
-
getType
- Returns:
- the type of the variant value
-
numObjectElements
public int numObjectElements()- Returns:
- the number of object fields in the variant
- Throws:
IllegalArgumentException- if `getType()` does not return `Type.OBJECT`
-
getFieldByKey
Returns the object field Variant value whose key is equal to `key`. Returns null if the key is not found.- Parameters:
key- the key to look up- Returns:
- the field value whose key is equal to `key`, or null if key is not found
- Throws:
IllegalArgumentException- if `getType()` does not return `Type.OBJECT`
-
getFieldAtIndex
Returns the field at index idx, lexicographically ordered.- Parameters:
idx- the index to look up- Returns:
- the field value whose key is equal to `key`, or null if key is not found
- Throws:
IllegalArgumentException- if `getType()` does not return `Type.OBJECT`
-
numArrayElements
public int numArrayElements()- Returns:
- the number of array elements
- Throws:
IllegalArgumentException- if `getType()` does not return `Type.ARRAY`
-
getElementAtIndex
Returns the array element Variant value at the `index` slot. Returns null if `index` is out of the bound of `[0, arraySize())`.- Parameters:
index- the index of the array element to get- Returns:
- the array element Variant at the `index` slot, or null if `index` is out of bounds
- Throws:
IllegalArgumentException- if `getType()` does not return `Type.ARRAY`
-