public class SpecificRecordBaseSerializerStrategy extends Object implements AvroSerializerStrategy
SpecificRecordBase.| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
void |
applyConfig(AvroSerializerStrategyConfig avroSerializerStrategyConfig)
Sets the configuration for the strategy.
|
<T> T |
deserializeFromGenericRecord(SerializedObject<org.apache.avro.generic.GenericRecord> serializedObject,
Class<T> readerType)
Deserializes from Apache Avro generic record (intermediate representation).
|
<T> T |
deserializeFromSingleObjectEncoded(SerializedObject<byte[]> serializedObject,
Class<T> readerType)
Deserializes from single object encoded byte array.
|
SerializedObject<byte[]> |
serializeToSingleObjectEncoded(Object object)
Serializes object to byte array using Avro single-object-encoding.
|
boolean |
test(Class<?> payloadType)
Determines if this strategy supports given
payloadType. |
public SpecificRecordBaseSerializerStrategy(org.apache.avro.message.SchemaStore schemaStore,
RevisionResolver revisionResolver,
SchemaIncompatibilityChecker schemaIncompatibilityChecker)
SpecificRecordBase.schemaStore - schema store to resolve schema from fingerprint.revisionResolver - revision resolver to find correct revision.schemaIncompatibilityChecker - stateful utility to perform compatibility checks.@Nonnull public SerializedObject<byte[]> serializeToSingleObjectEncoded(@Nonnull Object object)
AvroSerializerStrategyserializeToSingleObjectEncoded in interface AvroSerializerStrategyobject - object to serialize.@Nonnull public <T> T deserializeFromSingleObjectEncoded(@Nonnull SerializedObject<byte[]> serializedObject, @Nonnull Class<T> readerType)
AvroSerializerStrategydeserializeFromSingleObjectEncoded in interface AvroSerializerStrategyT - payload type to deserialize to.serializedObject - serialized object containing single-object-encoded bytes.readerType - class of resulting object.@Nonnull public <T> T deserializeFromGenericRecord(@Nonnull SerializedObject<org.apache.avro.generic.GenericRecord> serializedObject, @Nonnull Class<T> readerType)
AvroSerializerStrategydeserializeFromGenericRecord in interface AvroSerializerStrategyT - payload type to deserialize to.serializedObject - serialized object containing the generic record.readerType - class of resulting object.public boolean test(@Nonnull Class<?> payloadType)
AvroSerializerStrategypayloadType. 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.test in interface Predicate<Class<?>>test in interface AvroSerializerStrategypayloadType - The payload type of object to de-/serialize, for example BankAccountCreated.class.true if type is supported by this strategy, false otherwise.public void applyConfig(@Nonnull AvroSerializerStrategyConfig avroSerializerStrategyConfig)
AvroSerializerStrategyThis 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
applyConfig in interface AvroSerializerStrategyavroSerializerStrategyConfig - configuration passed by the builder.Copyright © 2010–2025. All rights reserved.