@Test public void testKafkaAvroSerializerReflectionRecordWithProjection() { byte[] bytes; Object obj; ExtendedWidget widget = new ExtendedWidget("alice", 20); Schema extendedWidgetSchema = ReflectData.get().getSchema(ExtendedWidget.class); Schema widgetSchema = ReflectData.get().getSchema(Widget.class); bytes = reflectionAvroSerializer.serialize(topic, widget); obj = reflectionAvroDecoder.fromBytes(bytes, extendedWidgetSchema); assertTrue( "Full object should be a io.confluent.kafka.example.ExtendedWidget", ExtendedWidget.class.isInstance(obj) ); assertEquals(widget, obj); obj = reflectionAvroDecoder.fromBytes(bytes, widgetSchema); assertTrue( "Projection object should be a io.confluent.kafka.example.Widget", Widget.class.isInstance(obj) ); assertEquals("alice", ((Widget) obj).getName()); obj = reflectionAvroDeserializer.deserialize(topic, bytes, extendedWidgetSchema); assertTrue( "Full object should be a io.confluent.kafka.example.ExtendedWidget", ExtendedWidget.class.isInstance(obj) ); assertEquals(widget, obj); obj = reflectionAvroDeserializer.deserialize(topic, bytes, widgetSchema); assertTrue( "Projection object should be a io.confluent.kafka.example.Widget", Widget.class.isInstance(obj) ); assertEquals("alice", ((Widget) obj).getName()); }
@Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); }
KafkaAvroSerializer extends AbstractKafkaAvroSerializer implements Serializer<Object> { @Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); } }
KafkaAvroSerializer extends AbstractKafkaAvroSerializer implements Serializer<Object> { @Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); } KafkaAvroSerializer();  KafkaAvroSerializer(SchemaRegistryClient client);  KafkaAvroSerializer(SchemaRegistryClient client, Map<String, ?> props); }
KafkaAvroSerializer extends AbstractKafkaAvroSerializer implements Serializer<Object> { @Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); } KafkaAvroSerializer();  KafkaAvroSerializer(SchemaRegistryClient client);  KafkaAvroSerializer(SchemaRegistryClient client, Map<String, ?> props); @Override void configure(Map<String, ?> configs, boolean isKey); @Override byte[] serialize(String topic, Object record); @Override void close(); }
KafkaAvroSerializer extends AbstractKafkaAvroSerializer implements Serializer<Object> { @Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); } KafkaAvroSerializer();  KafkaAvroSerializer(SchemaRegistryClient client);  KafkaAvroSerializer(SchemaRegistryClient client, Map<String, ?> props); @Override void configure(Map<String, ?> configs, boolean isKey); @Override byte[] serialize(String topic, Object record); @Override void close();  }