@Test public void testWithAvroRecord() throws IOException { Schema recordSchema = new Schema.Parser().parse(getClass().getClassLoader().getResourceAsStream("converter/fieldPickInput.avsc")); GenericData.Record record = new GenericData.Record(recordSchema); record.put("name", "foo"); RecordAccessor accessor = RecordAccessorProviderFactory.getRecordAccessorForObject(record); Assert.assertNotNull(accessor); Assert.assertEquals(accessor.getAsString("name"), "foo"); }
public synchronized static RecordAccessor getRecordAccessorForObject(Object obj) { for (RecordAccessorProvider p: recordAccessorProviders) { RecordAccessor accessor = p.recordAccessorForObject(obj); if (accessor != null) { return accessor; } } throw new IllegalArgumentException("Can't build accessor for object " + obj.toString() + "!"); }
RecordAccessorProviderFactory { public synchronized static RecordAccessor getRecordAccessorForObject(Object obj) { for (RecordAccessorProvider p: recordAccessorProviders) { RecordAccessor accessor = p.recordAccessorForObject(obj); if (accessor != null) { return accessor; } } throw new IllegalArgumentException("Can't build accessor for object " + obj.toString() + "!"); } }
RecordAccessorProviderFactory { public synchronized static RecordAccessor getRecordAccessorForObject(Object obj) { for (RecordAccessorProvider p: recordAccessorProviders) { RecordAccessor accessor = p.recordAccessorForObject(obj); if (accessor != null) { return accessor; } } throw new IllegalArgumentException("Can't build accessor for object " + obj.toString() + "!"); }  }
RecordAccessorProviderFactory { public synchronized static RecordAccessor getRecordAccessorForObject(Object obj) { for (RecordAccessorProvider p: recordAccessorProviders) { RecordAccessor accessor = p.recordAccessorForObject(obj); if (accessor != null) { return accessor; } } throw new IllegalArgumentException("Can't build accessor for object " + obj.toString() + "!"); }  synchronized static RecordAccessor getRecordAccessorForObject(Object obj); }
RecordAccessorProviderFactory { public synchronized static RecordAccessor getRecordAccessorForObject(Object obj) { for (RecordAccessorProvider p: recordAccessorProviders) { RecordAccessor accessor = p.recordAccessorForObject(obj); if (accessor != null) { return accessor; } } throw new IllegalArgumentException("Can't build accessor for object " + obj.toString() + "!"); }  synchronized static RecordAccessor getRecordAccessorForObject(Object obj);  }