@Test public void testCreateRecord() { assertNull("createRecord should not create Specific instances", DataModelUtil.createRecord(StandardEvent.class, StandardEvent.getClassSchema())); assertNull("createRecord should not create Reflect instances", DataModelUtil.createRecord(ReflectStandardEvent.class, ReflectData.get().getSchema(ReflectStandardEvent.class))); assertNotNull("createRecord should create Generic instances", DataModelUtil.createRecord(GenericData.Record.class, StandardEvent.getClassSchema())); assertEquals("createRecord did not return the expected class", TestGenericRecord.class, DataModelUtil.createRecord(TestGenericRecord.class, StandardEvent.getClassSchema()).getClass()); }
@SuppressWarnings("unchecked") public static <E> E createRecord(Class<E> type, Schema schema) { if (isGeneric(type) && !type.isInterface()) { if (GenericData.Record.class.equals(type)) { return (E) GenericData.get().newRecord(null, schema); } return (E) ReflectData.newInstance(type, schema); } return null; }
DataModelUtil { @SuppressWarnings("unchecked") public static <E> E createRecord(Class<E> type, Schema schema) { if (isGeneric(type) && !type.isInterface()) { if (GenericData.Record.class.equals(type)) { return (E) GenericData.get().newRecord(null, schema); } return (E) ReflectData.newInstance(type, schema); } return null; } }
DataModelUtil { @SuppressWarnings("unchecked") public static <E> E createRecord(Class<E> type, Schema schema) { if (isGeneric(type) && !type.isInterface()) { if (GenericData.Record.class.equals(type)) { return (E) GenericData.get().newRecord(null, schema); } return (E) ReflectData.newInstance(type, schema); } return null; }  }
DataModelUtil { @SuppressWarnings("unchecked") public static <E> E createRecord(Class<E> type, Schema schema) { if (isGeneric(type) && !type.isInterface()) { if (GenericData.Record.class.equals(type)) { return (E) GenericData.get().newRecord(null, schema); } return (E) ReflectData.newInstance(type, schema); } return null; }  static GenericData getDataModelForType(Class<E> type); static boolean isGeneric(Class<?> type); @SuppressWarnings("unchecked") static DatumReader<E> getDatumReaderForType(Class<E> type, Schema writerSchema); @SuppressWarnings("unchecked") static Class<E> resolveType(Class<E> type, Schema schema); static Schema getReaderSchema(Class<E> type, Schema schema); static Schema getWriterSchema(Class<E> type, Schema schema); @SuppressWarnings("unchecked") static E createRecord(Class<E> type, Schema schema); static EntityAccessor<E> accessor(Class<E> type, Schema schema); }
DataModelUtil { @SuppressWarnings("unchecked") public static <E> E createRecord(Class<E> type, Schema schema) { if (isGeneric(type) && !type.isInterface()) { if (GenericData.Record.class.equals(type)) { return (E) GenericData.get().newRecord(null, schema); } return (E) ReflectData.newInstance(type, schema); } return null; }  static GenericData getDataModelForType(Class<E> type); static boolean isGeneric(Class<?> type); @SuppressWarnings("unchecked") static DatumReader<E> getDatumReaderForType(Class<E> type, Schema writerSchema); @SuppressWarnings("unchecked") static Class<E> resolveType(Class<E> type, Schema schema); static Schema getReaderSchema(Class<E> type, Schema schema); static Schema getWriterSchema(Class<E> type, Schema schema); @SuppressWarnings("unchecked") static E createRecord(Class<E> type, Schema schema); static EntityAccessor<E> accessor(Class<E> type, Schema schema);  }