AnnotationBinder { public static void bind(final Object object, ICS ics) { if (object == null) { throw new IllegalArgumentException("Object cannot be null."); } if (ics == null) { throw new IllegalArgumentException("CS cannot be null."); } Class<?> c = object.getClass(); while (c != Object.class && c != null) { for (final Field field : c.getDeclaredFields()) { if (field.isAnnotationPresent(Bind.class)) { bindToField(object, ics, field); } } c = c.getSuperclass(); } }  static void bind(final Object object, ICS ics);  }
@Test public void testBind_csvar() { MyObject o = new MyObject(); ICS ics = new MockICS() { @Override public String GetVar(String key) { if (ftMessage.PageName.equals(key)) { return "hello"; } else if ("cid".equals(key)) { return "12345678901234"; } else if ("tid".equals(key)) { return "22345678901234"; } else if ("foo".equals(key)) { return "oof"; } return null; } }; AnnotationBinder.bind(o, ics); assertEquals("hello", o.pagename); assertEquals(12345678901234L, o.cid); assertEquals(new Long(22345678901234L), o.tid); assertNull(o.c); assertEquals("oof", o.bar); }