Class AbstractSerializer<T,U>

java.lang.Object
io.apicurio.registry.serde.AbstractSerializer<T,U>
All Implemented Interfaces:
AutoCloseable

public abstract class AbstractSerializer<T,U> extends Object implements AutoCloseable
  • Constructor Details

  • Method Details

    • schemaParser

      public abstract SchemaParser<T,U> schemaParser()
    • serializeData

      public abstract void serializeData(ParsedSchema<T> schema, U data, OutputStream out) throws IOException
      Throws:
      IOException
    • getSchemaCacheKey

      protected Object getSchemaCacheKey(U data)
      Gets a cache key for the schema associated with this data. For types where the schema is tied to the class (e.g., Avro SpecificRecord, Protobuf GeneratedMessage), this should return the class object. For types where the schema varies per instance (e.g., Avro GenericRecord), this should return an object that uniquely identifies the schema (e.g., the Schema object itself). For types where caching is not safe, this should return null. Subclasses should override this method to provide type-specific logic. The default implementation returns null (no caching).
      Parameters:
      data - the data to get a cache key for
      Returns:
      an object suitable as a cache key, or null if caching is not safe
    • configure

      public void configure(SerdeConfig config, boolean isKey)
    • serializeData

      public byte[] serializeData(String topic, U data)
    • getSerdeConfigurer

      public BaseSerde<T,U> getSerdeConfigurer()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable