2828/**
2929 * Schema Registry-based serializer implementation for Avro data format using Apache Avro.
3030 */
31- public final class SchemaRegistryApacheAvroEncoder {
31+ public final class SchemaRegistryApacheAvroSerializer {
3232 static final String AVRO_MIME_TYPE = "avro/binary" ;
3333 static final byte [] RECORD_FORMAT_INDICATOR = new byte []{0x00 , 0x00 , 0x00 , 0x00 };
3434 static final int RECORD_FORMAT_INDICATOR_SIZE = RECORD_FORMAT_INDICATOR .length ;
3535 static final int SCHEMA_ID_SIZE = 32 ;
3636
37- private final ClientLogger logger = new ClientLogger (SchemaRegistryApacheAvroEncoder .class );
37+ private final ClientLogger logger = new ClientLogger (SchemaRegistryApacheAvroSerializer .class );
3838 private final SchemaRegistryAsyncClient schemaRegistryClient ;
3939 private final AvroSerializer avroSerializer ;
4040 private final SerializerOptions serializerOptions ;
@@ -46,7 +46,7 @@ public final class SchemaRegistryApacheAvroEncoder {
4646 * @param avroSerializer Serializer implemented using Apache Avro.
4747 * @param serializerOptions Options to configure the serializer with.
4848 */
49- SchemaRegistryApacheAvroEncoder (SchemaRegistryAsyncClient schemaRegistryClient ,
49+ SchemaRegistryApacheAvroSerializer (SchemaRegistryAsyncClient schemaRegistryClient ,
5050 AvroSerializer avroSerializer , SerializerOptions serializerOptions ) {
5151 this .schemaRegistryClient = Objects .requireNonNull (schemaRegistryClient ,
5252 "'schemaRegistryClient' cannot be null." );
@@ -56,84 +56,84 @@ public final class SchemaRegistryApacheAvroEncoder {
5656 }
5757
5858 /**
59- * Encodes an object into a message.
59+ * Serializes an object into a message.
6060 *
61- * @param object Object to encode .
61+ * @param object Object to serialize .
6262 * @param typeReference Type of message to create.
6363 * @param <T> Concrete type of {@link MessageWithMetadata}.
6464 *
65- * @return The message encoded or {@code null} if the message could not be encoded .
65+ * @return The message encoded or {@code null} if the message could not be serialized .
6666 *
6767 * @throws IllegalArgumentException if {@code messageFactory} is null and type {@code T} does not have a no
68- * argument constructor. Or if the schema could not ve fetched from {@code T}.
68+ * argument constructor. Or if the schema could not be fetched from {@code T}.
6969 * @throws RuntimeException if an instance of {@code T} could not be instantiated. Or there was a problem
7070 * encoding the object.
7171 * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null.
7272 */
73- public <T extends MessageWithMetadata > T encodeMessageData (Object object , TypeReference <T > typeReference ) {
74- return encodeMessageDataAsync (object , typeReference ).block ();
73+ public <T extends MessageWithMetadata > T serializeMessageData (Object object , TypeReference <T > typeReference ) {
74+ return serializeMessageDataAsync (object , typeReference ).block ();
7575 }
7676
7777 /**
78- * Encodes an object into a message.
78+ * Serializes an object into a message.
7979 *
80- * @param object Object to encode .
80+ * @param object Object to serialize .
8181 * @param typeReference Type of message to create.
8282 * @param messageFactory Factory to create an instance given the serialized Avro.
8383 * @param <T> Concrete type of {@link MessageWithMetadata}.
8484 *
85- * @return The message encoded or {@code null} if the message could not be encoded .
85+ * @return The message encoded or {@code null} if the message could not be serialized .
8686 *
8787 * @throws IllegalArgumentException if {@code messageFactory} is null and type {@code T} does not have a no
88- * argument constructor. Or if the schema could not ve fetched from {@code T}.
88+ * argument constructor. Or if the schema could not be fetched from {@code T}.
8989 * @throws RuntimeException if an instance of {@code T} could not be instantiated. Or there was a problem
9090 * encoding the object.
9191 * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null.
9292 */
93- public <T extends MessageWithMetadata > T encodeMessageData (Object object , TypeReference <T > typeReference ,
93+ public <T extends MessageWithMetadata > T serializeMessageData (Object object , TypeReference <T > typeReference ,
9494 Function <BinaryData , T > messageFactory ) {
95- return encodeMessageDataAsync (object , typeReference , messageFactory ).block ();
95+ return serializeMessageDataAsync (object , typeReference , messageFactory ).block ();
9696 }
9797
9898 /**
99- * Encodes an object into a message.
99+ * Serializes an object into a message.
100100 *
101- * @param object Object to encode .
101+ * @param object Object to serialize .
102102 * @param typeReference Type of message to create.
103103 * @param <T> Concrete type of {@link MessageWithMetadata}.
104104 *
105- * @return A Mono that completes with the encoded message.
105+ * @return A Mono that completes with the serialized message.
106106 *
107107 * @throws IllegalArgumentException if {@code messageFactory} is null and type {@code T} does not have a no
108- * argument constructor. Or if the schema could not ve fetched from {@code T}.
108+ * argument constructor. Or if the schema could not be fetched from {@code T}.
109109 * @throws RuntimeException if an instance of {@code T} could not be instantiated. Or there was a problem
110110 * encoding the object.
111111 * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null.
112112 */
113- public <T extends MessageWithMetadata > Mono <T > encodeMessageDataAsync (Object object ,
113+ public <T extends MessageWithMetadata > Mono <T > serializeMessageDataAsync (Object object ,
114114 TypeReference <T > typeReference ) {
115115
116- return encodeMessageDataAsync (object , typeReference , null );
116+ return serializeMessageDataAsync (object , typeReference , null );
117117 }
118118
119119 /**
120- * Encodes an object into a message.
120+ * Serializes an object into a message.
121121 *
122- * @param object Object to encode .
122+ * @param object Object to serialize .
123123 * @param typeReference Type of message to create.
124124 * @param messageFactory Factory to create an instance given the serialized Avro. If null is passed in, then the
125125 * no argument constructor will be used.
126126 * @param <T> Concrete type of {@link MessageWithMetadata}.
127127 *
128- * @return A Mono that completes with the encoded message.
128+ * @return A Mono that completes with the serialized message.
129129 *
130130 * @throws IllegalArgumentException if {@code messageFactory} is null and type {@code T} does not have a no
131- * argument constructor. Or if the schema could not ve fetched from {@code T}.
131+ * argument constructor. Or if the schema could not be fetched from {@code T}.
132132 * @throws RuntimeException if an instance of {@code T} could not be instantiated. Or there was a problem
133133 * encoding the object.
134134 * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null.
135135 */
136- public <T extends MessageWithMetadata > Mono <T > encodeMessageDataAsync (Object object ,
136+ public <T extends MessageWithMetadata > Mono <T > serializeMessageDataAsync (Object object ,
137137 TypeReference <T > typeReference , Function <BinaryData , T > messageFactory ) {
138138
139139 if (object == null ) {
@@ -189,33 +189,33 @@ public <T extends MessageWithMetadata> Mono<T> encodeMessageDataAsync(Object obj
189189 }
190190
191191 /**
192- * Decodes a message into its object.
192+ * Deserializes a message into its object.
193193 *
194- * @param message Object to encode .
195- * @param typeReference Message to encode to.
194+ * @param message Object to deserialize .
195+ * @param typeReference Message type to deserialize to.
196196 * @param <T> Concrete type of {@link MessageWithMetadata}.
197197 *
198- * @return The message encoded .
198+ * @return The message deserialized .
199199 *
200200 * @throws NullPointerException if {@code message} or {@code typeReference} is null.
201201 */
202- public <T > T decodeMessageData (MessageWithMetadata message , TypeReference <T > typeReference ) {
203- return decodeMessageDataAsync (message , typeReference ).block ();
202+ public <T > T deserializeMessageData (MessageWithMetadata message , TypeReference <T > typeReference ) {
203+ return deserializeMessageDataAsync (message , typeReference ).block ();
204204 }
205205
206206 /**
207- * Decodes a message into its object.
207+ * Deserializes a message into its object.
208208 *
209- * @param message Object to encode .
210- * @param typeReference Message to encode to.
209+ * @param message Object to deserialize .
210+ * @param typeReference Message to deserialize to.
211211 * @param <T> Concrete type of {@link MessageWithMetadata}.
212212 *
213213 * @return A Mono that completes when the message encoded. If {@code message.getBodyAsBinaryData()} is null or
214214 * empty, then an empty Mono is returned.
215215 *
216216 * @throws NullPointerException if {@code message} or {@code typeReference} is null.
217217 */
218- public <T > Mono <T > decodeMessageDataAsync (MessageWithMetadata message , TypeReference <T > typeReference ) {
218+ public <T > Mono <T > deserializeMessageDataAsync (MessageWithMetadata message , TypeReference <T > typeReference ) {
219219 if (message == null ) {
220220 return monoError (logger , new NullPointerException ("'message' cannot be null." ));
221221 } else if (typeReference == null ) {
@@ -282,10 +282,10 @@ public <T> Mono<T> decodeMessageDataAsync(MessageWithMetadata message, TypeRefer
282282 contents .reset ();
283283 }
284284
285- return decodeMessageDataAsync (schemaId , contents , typeReference );
285+ return deserializeMessageDataAsync (schemaId , contents , typeReference );
286286 }
287287
288- private <T > Mono <T > decodeMessageDataAsync (String schemaId , ByteBuffer buffer , TypeReference <T > typeReference ) {
288+ private <T > Mono <T > deserializeMessageDataAsync (String schemaId , ByteBuffer buffer , TypeReference <T > typeReference ) {
289289 return this .schemaRegistryClient .getSchema (schemaId )
290290 .handle ((registryObject , sink ) -> {
291291 final byte [] payloadSchema = registryObject .getDefinition ().getBytes (StandardCharsets .UTF_8 );
0 commit comments