@ SuppressWarnings ( "unchecked" ) public static < E > DatumReader < E > getDatumReaderForType ( Class < E > type , Schema writerSchema ) { Schema readerSchema = getReaderSchema ( type , writerSchema ) ; GenericData dataModel = getDataModelForType ( type ) ; if ( dataModel instanceof ReflectData ) { return new ReflectDatumReader < E > ( writerSchema , readerSchema , ( ReflectData ) dataModel ) ; } else if ( dataModel instanceof SpecificData ) { return new SpecificDatumReader < E > ( writerSchema , readerSchema , ( SpecificData ) dataModel ) ; } else { return new GenericDatumReader < E > ( writerSchema , readerSchema , dataModel ) ; } }
Get the DatumReader for the given type .