GenericRecordBuilder implements Closeable { public Class<? extends SpecificRecordBase> getRecordClass(final Schema schema) { Preconditions.checkArgument(SchemaUtils.isNamedType(schema), "schema %s has no java class", schema); try { return (Class<? extends SpecificRecordBase>) source.loadClass(SchemaUtils.getJavaClassName(schema)); } catch (ClassNotFoundException ex) { throw new IllegalStateException(ex); } } GenericRecordBuilder(final Schema... schemas);  GenericRecordBuilder(final GenericData.StringType stringType, final Schema... schemas); Class<? extends SpecificRecordBase> getRecordClass(final Schema schema); Class<? extends GenericEnumSymbol> getEnumClass(final Schema schema); Class<? extends GenericFixed> getFixedClass(final Schema schema); @Override void close(); @Override String toString();  }
@Test @SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS") public void testMoreGenericRecordCreation() throws InstantiationException, IllegalAccessException { Schema reuse = SchemaBuilder.builder().record("Reuse").fields().requiredString("field").endRecord(); Schema record = SchemaBuilder.builder().record("TestRecord").fields() .requiredInt("number") .name("record").type(reuse).noDefault() .endRecord(); Schema record2 = SchemaBuilder.builder().record("TestRecord2").fields() .requiredBoolean("isThere") .name("record").type(reuse).noDefault() .endRecord(); try (GenericRecordBuilder builder = new GenericRecordBuilder(record, record2)) { Class<? extends SpecificRecordBase> clasz = builder.getRecordClass(record); Class<? extends SpecificRecordBase> clasz2 = builder.getRecordClass(record); Assert.assertSame(clasz, clasz2); SpecificRecordBase myRecord = clasz.newInstance(); myRecord.put("number", 35); Assert.assertEquals(35, (int) myRecord.get("number")); Class<? extends SpecificRecordBase> aClass = builder.getRecordClass(record2); GenericRecord r2 = aClass.newInstance(); LOG.debug("Record = {}", r2); } }