@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);
    }
  }
@ 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.

@param <E> The entity type
@param type The Java class of the entity type
@param writerSchema The {@link Schema} for entities
@return The DatumReader for the given type