* @return A deserializer for objects of class <code>c</code>.
*/
@Override
public Deserializer<AvroWrapper<T>> getDeserializer(Class<AvroWrapper<T>> c) {
Configuration conf = getConf();
GenericData dataModel = createDataModel(conf);
if (AvroKey.class.isAssignableFrom(c)) {
Schema writerSchema = getKeyWriterSchema(conf);
Schema readerSchema = getKeyReaderSchema(conf);
DatumReader<T> datumReader = (readerSchema != null)
? dataModel.createDatumReader(writerSchema, readerSchema)
: dataModel.createDatumReader(writerSchema);
return new AvroKeyDeserializer<T>(writerSchema, readerSchema, datumReader);
} else if (AvroValue.class.isAssignableFrom(c)) {
Schema writerSchema = getValueWriterSchema(conf);
Schema readerSchema = getValueReaderSchema(conf);
DatumReader<T> datumReader = (readerSchema != null)
? dataModel.createDatumReader(writerSchema, readerSchema)
: dataModel.createDatumReader(writerSchema);
return new AvroValueDeserializer<T>(writerSchema, readerSchema, datumReader);
} else {
throw new IllegalStateException("Only AvroKey and AvroValue are supported.");
}
}