@Test void createJDBCInput() throws Exception { final CustomJdbcIO.Read read = new AutoValueFluentApiFactory().create(CustomJdbcIO.Read.class, "read", new HashMap<String, Object>() { { put("dataSourceConfiguration.driverClassName", "org.h2.Driver"); put("dataSourceConfiguration.url", "jdbc:h2:mem:test"); put("dataSourceConfiguration.username", "sa"); put("query", "select * from user"); put("rowMapper", (CustomJdbcIO.RowMapper<JsonObject>) resultSet -> null); } }); final CustomJdbcIO.DataSourceConfiguration dataSourceConfiguration = readField(read, "dataSourceConfiguration", CustomJdbcIO.DataSourceConfiguration.class); assertNotNull(dataSourceConfiguration); assertEquals("org.h2.Driver", readField(dataSourceConfiguration, "driverClassName", String.class)); assertEquals("jdbc:h2:mem:test", readField(dataSourceConfiguration, "url", String.class)); assertEquals("sa", readField(dataSourceConfiguration, "username", String.class)); assertNull(readField(dataSourceConfiguration, "password", String.class)); assertEquals("select * from user", readField(read, "query", ValueProvider.class).get()); assertNotNull(readField(read, "rowMapper", CustomJdbcIO.RowMapper.class)); }
public <T> T create(final Class<T> base, final String factoryMethod, final Map<String, Object> config) { try { final Method method = findFactory(base, factoryMethod); return base.cast(setConfig(method.invoke(null), config, "")); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final InvocationTargetException e) { throw new IllegalStateException(e.getTargetException()); } }
AutoValueFluentApiFactory implements Serializable { public <T> T create(final Class<T> base, final String factoryMethod, final Map<String, Object> config) { try { final Method method = findFactory(base, factoryMethod); return base.cast(setConfig(method.invoke(null), config, "")); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final InvocationTargetException e) { throw new IllegalStateException(e.getTargetException()); } } }
AutoValueFluentApiFactory implements Serializable { public <T> T create(final Class<T> base, final String factoryMethod, final Map<String, Object> config) { try { final Method method = findFactory(base, factoryMethod); return base.cast(setConfig(method.invoke(null), config, "")); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final InvocationTargetException e) { throw new IllegalStateException(e.getTargetException()); } }  }
AutoValueFluentApiFactory implements Serializable { public <T> T create(final Class<T> base, final String factoryMethod, final Map<String, Object> config) { try { final Method method = findFactory(base, factoryMethod); return base.cast(setConfig(method.invoke(null), config, "")); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final InvocationTargetException e) { throw new IllegalStateException(e.getTargetException()); } }  T create(final Class<T> base, final String factoryMethod, final Map<String, Object> config); }
AutoValueFluentApiFactory implements Serializable { public <T> T create(final Class<T> base, final String factoryMethod, final Map<String, Object> config) { try { final Method method = findFactory(base, factoryMethod); return base.cast(setConfig(method.invoke(null), config, "")); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final InvocationTargetException e) { throw new IllegalStateException(e.getTargetException()); } }  T create(final Class<T> base, final String factoryMethod, final Map<String, Object> config);  }