Class SpecificRecordBaseSerializerStrategy

java.lang.Object
org.axonframework.serialization.avro.SpecificRecordBaseSerializerStrategy
All Implemented Interfaces:
Predicate<Class<?>>, AvroSerializerStrategy

public class SpecificRecordBaseSerializerStrategy extends Object implements AvroSerializerStrategy
Avro serializer strategy responsible for operations on SpecificRecordBase.
Since:
4.11.0
Author:
Simon Zambrovski, Jan Galinski
  • Constructor Details

    • SpecificRecordBaseSerializerStrategy

      public SpecificRecordBaseSerializerStrategy(org.apache.avro.message.SchemaStore schemaStore, RevisionResolver revisionResolver, SchemaIncompatibilityChecker schemaIncompatibilityChecker)
      Constructs avro serialization strategy supporting serialization and deserialization of Java Avro classes extending SpecificRecordBase.
      Parameters:
      schemaStore - schema store to resolve schema from fingerprint.
      revisionResolver - revision resolver to find correct revision.
      schemaIncompatibilityChecker - stateful utility to perform compatibility checks.
  • Method Details

    • serializeToSingleObjectEncoded

      @Nonnull public SerializedObject<byte[]> serializeToSingleObjectEncoded(@Nonnull Object object)
      Description copied from interface: AvroSerializerStrategy
      Serializes object to byte array using Avro single-object-encoding.
      Specified by:
      serializeToSingleObjectEncoded in interface AvroSerializerStrategy
      Parameters:
      object - object to serialize.
      Returns:
      byte array.
    • deserializeFromSingleObjectEncoded

      @Nonnull public <T> T deserializeFromSingleObjectEncoded(@Nonnull SerializedObject<byte[]> serializedObject, @Nonnull Class<T> readerType)
      Description copied from interface: AvroSerializerStrategy
      Deserializes from single object encoded byte array.
      Specified by:
      deserializeFromSingleObjectEncoded in interface AvroSerializerStrategy
      Type Parameters:
      T - payload type to deserialize to.
      Parameters:
      serializedObject - serialized object containing single-object-encoded bytes.
      readerType - class of resulting object.
      Returns:
      deserialized object.
    • deserializeFromGenericRecord

      @Nonnull public <T> T deserializeFromGenericRecord(@Nonnull SerializedObject<org.apache.avro.generic.GenericRecord> serializedObject, @Nonnull Class<T> readerType)
      Description copied from interface: AvroSerializerStrategy
      Deserializes from Apache Avro generic record (intermediate representation).
      Specified by:
      deserializeFromGenericRecord in interface AvroSerializerStrategy
      Type Parameters:
      T - payload type to deserialize to.
      Parameters:
      serializedObject - serialized object containing the generic record.
      readerType - class of resulting object.
      Returns:
      deserialized object.
    • test

      public boolean test(@Nonnull Class<?> payloadType)
      Description copied from interface: AvroSerializerStrategy
      Determines if this strategy supports given payloadType. This means that we have either a SpecificRecordBase generated from a schema using apache-avro-maven-plugin or a kotlinx serializable class, written using avro4k.
      Specified by:
      test in interface AvroSerializerStrategy
      Specified by:
      test in interface Predicate<Class<?>>
      Parameters:
      payloadType - The payload type of object to de-/serialize, for example BankAccountCreated.class.
      Returns:
      true if type is supported by this strategy, false otherwise.
    • applyConfig

      public void applyConfig(@Nonnull AvroSerializerStrategyConfig avroSerializerStrategyConfig)
      Description copied from interface: AvroSerializerStrategy
      Sets the configuration for the strategy.

      This method is called by the AvroSerializer.Builder during instantiation of AvroSerializer, passing the builder configuration to the strategy. The default implementation does nothing, but a strategy might use this method to set up internals.

      This method is intended to be implemented by the strategy, if it supports configuration options set by the AvroSerializer.Builder, passed via AvroSerializerStrategyConfig

      Specified by:
      applyConfig in interface AvroSerializerStrategy
      Parameters:
      avroSerializerStrategyConfig - configuration passed by the builder.