/** * Creates a new instance of an {@link IndexedRecordConverter} that can be used to wrap or convert objects of the * specified class into {@link IndexedRecord}. * <p> * As a general rule, when the expected output {@link Schema} of the generated {@link IndexedRecord} is the same for * all incoming data, the factory should be cached and reused to optimize its performance. * * @param datumClass The class of the object that the {@link IndexedRecordConverter} knows how to wrap. * @return A new {@link IndexedRecordConverter} that can process instances of the datumClass, or null if none * exists. */ public <DatumT> IndexedRecordConverter<? super DatumT, ?> createIndexedRecordConverter(Class<DatumT> datumClass) { // This is guaranteed to be correctly typed if it exists, because of the register methods. @SuppressWarnings({ "rawtypes", "unchecked" }) Supplier<? extends IndexedRecordConverter<DatumT, ?>> converter = (Supplier) getFromClassRegistry( mapSharedIndexedRecordConverter, datumClass); if (converter == null && IndexedRecord.class.isAssignableFrom(datumClass)) { @SuppressWarnings("unchecked") IndexedRecordConverter<DatumT, ?> unconverted = (IndexedRecordConverter<DatumT, ?>) new UnconvertedIndexedRecordConverter<>(); return unconverted; } return converter == null ? null : converter.get(); }