Interface AvroSerializerStrategy
- All Known Implementing Classes:
SpecificRecordBaseSerializerStrategy
Serialization strategy for Avro Serializer.
- Since:
- 4.11.0
- Author:
- Simon Zambrovski, Jan Galinski
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidapplyConfig(AvroSerializerStrategyConfig avroSerializerStrategyConfig) Sets the configuration for the strategy.<T> TdeserializeFromGenericRecord(SerializedObject<org.apache.avro.generic.GenericRecord> serializedObject, Class<T> type) Deserializes from Apache Avro generic record (intermediate representation).<T> TdeserializeFromSingleObjectEncoded(SerializedObject<byte[]> serializedObject, Class<T> type) Deserializes from single object encoded byte array.SerializedObject<byte[]> serializeToSingleObjectEncoded(Object object) Serializes object to byte array using Avro single-object-encoding.booleanDetermines if this strategy supports givenpayloadType.
-
Method Details
-
test
Determines if this strategy supports givenpayloadType. This means that we have either aSpecificRecordBasegenerated from a schema using apache-avro-maven-plugin or a kotlinx serializable class, written using avro4k. -
serializeToSingleObjectEncoded
Serializes object to byte array using Avro single-object-encoding.- Parameters:
object- object to serialize.- Returns:
- byte array.
-
deserializeFromSingleObjectEncoded
@Nonnull <T> T deserializeFromSingleObjectEncoded(@Nonnull SerializedObject<byte[]> serializedObject, @Nonnull Class<T> type) Deserializes from single object encoded byte array.- Type Parameters:
T- payload type to deserialize to.- Parameters:
serializedObject- serialized object containing single-object-encoded bytes.type- class of resulting object.- Returns:
- deserialized object.
-
deserializeFromGenericRecord
<T> T deserializeFromGenericRecord(SerializedObject<org.apache.avro.generic.GenericRecord> serializedObject, Class<T> type) Deserializes from Apache Avro generic record (intermediate representation).- Type Parameters:
T- payload type to deserialize to.- Parameters:
serializedObject- serialized object containing the generic record.type- class of resulting object.- Returns:
- deserialized object.
-
applyConfig
Sets the configuration for the strategy.This method is called by the
AvroSerializer.Builderduring instantiation ofAvroSerializer, 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 viaAvroSerializerStrategyConfig- Parameters:
avroSerializerStrategyConfig- configuration passed by the builder.
-