@Test public void testJavaBeanBindParse() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.stringTest", 123); map.put("hmily.integerTest", "123"); map.put("hmily.doubleTest", "123"); map.put("hmily.longTest", "123"); map.put("hmily.chartTest", "A"); map.put("hmily.floatTest", "123"); map.put("hmily.boolTest", "true"); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>(propertySource, PropertyKeyParse.INSTANCE); Binder binder = Binder.of(configPropertySource); BindData<JavaBeanBinderTest> data = BindData.of(DataType.of(JavaBeanBinderTest.class), JavaBeanBinderTest::new); JavaBeanBinderTest bind = binder.bind("hmily", data); Assert.assertEquals("123", bind.getStringTest()); Assert.assertEquals(Integer.valueOf(123), bind.getIntegerTest()); Assert.assertEquals(Double.valueOf(123), bind.getDoubleTest()); Assert.assertEquals(Character.valueOf('A'), bind.getChartTest()); Assert.assertEquals(Long.valueOf(123), bind.getLongTest()); Assert.assertEquals(Float.valueOf(123), bind.getFloatTest()); Assert.assertEquals(Boolean.TRUE, bind.getBoolTest()); }
@Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; }
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; } }
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; }  }
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; }  @Override T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder); }
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier<T> beanSupplier = bean.getSupplier(target); boolean bound = bind(propertyBinder, bean, beanSupplier); return bound ? beanSupplier.get() : null; }  @Override T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder);  }