Class AbstractSchema<T>

java.lang.Object
org.apache.pulsar.client.impl.schema.AbstractSchema<T>
All Implemented Interfaces:
Cloneable, Schema<T>
Direct Known Subclasses:
AbstractStructSchema, BooleanSchema, ByteBufferSchema, ByteBufSchema, ByteSchema, BytesSchema, DateSchema, DoubleSchema, FloatSchema, InstantSchema, IntSchema, KeyValueSchemaImpl, LocalDateSchema, LocalDateTimeSchema, LocalTimeSchema, LongSchema, ShortSchema, StringSchema, TimeSchema, TimestampSchema

public abstract class AbstractSchema<T> extends Object implements Schema<T>
  • Constructor Details

    • AbstractSchema

      public AbstractSchema()
  • Method Details

    • decode

      public abstract T decode(io.netty.buffer.ByteBuf byteBuf)
      Decode a byteBuf into an object using the schema definition and deserializer implementation

      Do not modify reader/writer index of ByteBuf so, it can be reused to access correct data.

      Parameters:
      byteBuf - the byte buffer to decode
      Returns:
      the deserialized object
    • decode

      public T decode(io.netty.buffer.ByteBuf byteBuf, byte[] schemaVersion)
      Decode a byteBuf into an object using a given version.
      Parameters:
      byteBuf - the byte array to decode
      schemaVersion - the schema version to decode the object. null indicates using latest version.
      Returns:
      the deserialized object
    • clone

      public Schema<T> clone()
      Specified by:
      clone in interface Schema<T>
      Overrides:
      clone in class Object
    • atSchemaVersion

      public Schema<?> atSchemaVersion(byte[] schemaVersion) throws SchemaSerializationException
      Return an instance of this schema at the given version.
      Parameters:
      schemaVersion - the version
      Returns:
      the schema at that specific version
      Throws:
      SchemaSerializationException - in case of unknown schema version
      NullPointerException - in case of null schemaVersion and supportSchemaVersioning is true