### Question:
Binder { public <T> T bind(Class<T> clazz) { return bind(clazz, Strings.DOT); }  T bind(Class<T> clazz); T bind(Class<T> clazz, String prefix); T bind(T obj, String prefix);  }### Answer:
@Test public void bind() { Binder binder = new Binder(BinderTest::props); Obj obj = binder.bind(Obj.class); Assert.assertEquals("1", obj.f1); Assert.assertEquals("3", obj.f2); Obj1 obj1 = binder.bind(Obj1.class); Assert.assertEquals("4", obj1.f1); Assert.assertEquals("3", obj1.f2); }
@Test public void testBind() { Binder binder = new Binder(BinderTest::props); Obj obj = binder.bind(Obj.class, "lc"); Assert.assertEquals("4", obj.f1); Assert.assertEquals("3", obj.f2); Obj1 obj1 = binder.bind(Obj1.class, "rp"); Assert.assertEquals("6", obj1.f1); Assert.assertEquals("3", obj1.f2); Assert.assertNotNull(obj1.f3); Assert.assertEquals("7", obj1.f3.f1); Assert.assertEquals("3", obj1.f3.f2); }
@Test public void testBind1() { Binder binder = new Binder(BinderTest::props); Obj obj = new Obj(); obj.f1 = "8"; obj.f2 = "9"; binder.bind(obj, "lc"); Assert.assertEquals("4", obj.f1); Assert.assertEquals("3", obj.f2); Obj obj1 = new Obj(); obj1.f1 = "8"; obj1.f2 = "9"; binder.bind(obj1, "rp"); Assert.assertEquals("6", obj1.f1); Assert.assertEquals("3", obj1.f2); }
@Test public void testArray() { Properties prop = new Properties(); prop.setProperty("f1", "1"); prop.setProperty("f2", "2"); prop.setProperty("f3", "3,1"); Binder binder = new Binder(() -> prop); Obj obj = binder.bind(Obj.class); Assert.assertNotNull(obj.f3); Assert.assertEquals(2, obj.f3.length); Assert.assertEquals(new Integer(3), obj.f3[0]); }