ConfigFactory { public static Config fromBean(Class<?> c, Object o) { return from(toConfigMap(c, o)); } private  ConfigFactory(); static Config fromMap(Map<String, ? extends Object> m); static Config fromProperties(Properties m); static Config from(ConfigMap m); static ReplaceableConfigMap replaceable(ConfigMap m); static ConfigMap chain(ConfigMap ... m); static ConfigMap chain(Iterable<ConfigMap> m); @SuppressWarnings("unchecked") static T bind(Config config, Class<? extends T> clazz); @SuppressWarnings("unchecked") static T bind(Config config, Class<? extends T> clazz, BindConfig bc); static Config fromBean(Class<?> c, Object o); static String prettyPrint(Config c); static ConfigMap toConfigMap(Map<?, ? extends Object> m); static ConfigMap toConfigMap(Class<?> clazz, Object target); static String validatePath(String path); static boolean isKey(String s); static boolean isSubPath(String parentPath, String childPath); static String joinPath(List<String> elements); static List<String> splitPath(String path); static String parentPath(String path); static Set<String> filterParentPaths(Iterator<String> paths);  }
@Test public void testFromBean() throws Exception { Example e = new Example() { @Override public Supplier<String> getHost() { return Suppliers.ofInstance("hello"); } @Override public int getPort() { return 90; } @Override public String getUser() { return "admin"; } @Override public boolean isAuto() { return true; } @Override public Optional<String> alias() { return Optional.of("demo"); } }; Config c = ConfigFactory.fromBean(Example.class, e); assertEquals("hello", c.getString("host").get()); assertEquals(90, c.getInteger("port").get().intValue()); assertEquals(true, c.getBoolean("auto").get().booleanValue()); assertEquals("demo", c.getString("alias").get()); }