java.lang.Object
io.confluent.kafka.schemaregistry.type.Variant

public final class Variant extends Object
This Variant class holds the Variant-encoded value and metadata binary values.
  • 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

      public Variant(ByteBuffer value, ByteBuffer metadata)
  • Method Details

    • getValueBuffer

      public ByteBuffer getValueBuffer()
    • getMetadataBuffer

      public ByteBuffer 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

      public BigDecimal getDecimal()
      Returns:
      the decimal value
    • getFloat

      public float getFloat()
      Returns:
      the float value
    • getBinary

      public ByteBuffer getBinary()
      Returns:
      the binary value
    • getUUID

      public UUID getUUID()
      Returns:
      the UUID value
    • getString

      public String getString()
      Returns:
      the string value
    • getType

      public Variant.Type 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

      public Variant getFieldByKey(String key)
      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

      public Variant.ObjectField getFieldAtIndex(int idx)
      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

      public Variant getElementAtIndex(int index)
      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`