DLListboxComponentControllerImpl implements DLListboxComponentController<T> { protected static Class getFieldType( final Class cls, final String key ) { if ( key.length() == 0 ) { return cls; } final int index = key.indexOf( '.' ); final String name = index == -1 ? key : key.substring( 0, index ); final String newKey = index == -1 ? "" : key.substring( index + 1 ); for ( java.lang.reflect.Field field : ReflectionHelper.getAllFields(cls) ) { if ( field.getName().equals( name ) ) { return getFieldType( field.getType(), newKey ); } } String getterMethodName = "get" + name.substring(0,1).toUpperCase() + name.substring(1); for ( Method method : ReflectionHelper.getAllMethods(cls) ) { if ( method.getName().equals( getterMethodName )) { return getFieldType( method.getReturnType(), newKey ); } } return null; } DLListboxComponentControllerImpl( final DLListboxExtController<T> masterController, final DLColumnModel columnModel, final DLListbox listbox ); void onSort( final DLListheader listheader ); void onCreate(); void fireChanges(); void fireDataChanges(); void fireColumnModelChanges(); void refreshBindingAll(); @SuppressWarnings( "unchecked" ) void fireOrderChanges(); void updateListItem( Listitem item ); void setListboxModel( final List<T> model ); @Deprecated @SuppressWarnings( "unchecked" ) void setRendererTemplate( final Listitem item ); void setRendererTemplate( final Template template ); T getSelectedItem(); void setSelected( final T selectedItem ); void setSelected( final T selectedItem, final Set<T> selectedItems ); void setSelectedItem( final T selectedItem ); Set<T> getSelectedItems(); void setSelectedItems( Set<T> selectedItems ); int getSelectedIndex(); void setSelectedIndex( final int selectedIndex ); boolean updateItem(T item); Component getFellow( final String compId ); void addForward( final String originEvent, final String targetComponent, final String targetEvent ); void addForward( final String originalEvent, final Component target, final String targetEvent ); Composer getWindowCtl(); void focus(); boolean isLoadDataOnCreate(); DLListbox getListbox(); String getUuidsForTest(); List<T> getListboxModel(); @Override boolean clearInPagingEvents();  }
@Test public void testGetFieldType() throws Exception { assertEquals(String.class, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "stringProp")); assertEquals(String.class, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "stringPropNoGetters")); assertEquals(Integer.TYPE, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "intProp")); assertEquals(Integer.class, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "integerProp")); assertEquals(TestClass.TestClassPK.class, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "pk")); assertEquals(TestClass.class, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "loop")); assertEquals(Integer.TYPE, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "pk.pk1")); assertEquals(String.class, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "pk.pk2")); assertEquals(BigDecimal.class, DLListboxComponentControllerImpl.getFieldType(TestClass.class, "transientProp")); assertNull(DLListboxComponentControllerImpl.getFieldType(TestClass.class, "non")); }