Package org.dellroad.stuff.vaadin8
Class GridColumnScanner<T>
- java.lang.Object
-
- org.dellroad.stuff.vaadin8.GridColumnScanner<T>
-
- Type Parameters:
T- Java class to be introspected
public class GridColumnScanner<T> extends Object
Scans a Java class hierarchy for@GridColumnannotated getter methods, and auto-generates and configures correspondingGrid.Columns on aGridinstance.This class will also introspect for
FieldBuilderannotations and configure editor bindings accordingly viaFieldBuilder.setEditorBindings(com.vaadin.ui.Grid<T>).See
GridColumnfor an example of usage.
-
-
Constructor Summary
Constructors Constructor Description GridColumnScanner(Class<T> type)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Grid<T>buildGrid()Build aGridwith columns auto-generated from introspected@GridColumnannotations.<G extends Grid<T>>
GbuildGrid(Function<? super PropertySet<T>,G> creator)Build aGridwith columns auto-generated from introspected@GridColumnannotations, using the given function to instantiate theGrid.Map<String,MethodAnnotationScanner.MethodInfo>getColumnMap()Get the annotations found through introspection keyed by property name.protected StringgetPropertyName(MethodAnnotationScanner.MethodInfo methodInfo)Get the property name from the annotation.Class<T>getType()Get the type associated with this instance.
-
-
-
Constructor Detail
-
GridColumnScanner
public GridColumnScanner(Class<T> type)
Constructor.- Parameters:
type- Java class to be introspected- Throws:
IllegalArgumentException- iftypeis nullIllegalArgumentException- if an annotated method with no property name specified has a name which cannot be interpreted as a bean property "getter" methodIllegalArgumentException- iftypehas two@GridColumn-annotated fields or methods with the same property name
-
-
Method Detail
-
buildGrid
public Grid<T> buildGrid()
Build aGridwith columns auto-generated from introspected@GridColumnannotations.The implementation in
GridColumnScannersimply invokesthis.buildGrid(Grid::withPropertySet).- Returns:
- new
Grid
-
buildGrid
public <G extends Grid<T>> G buildGrid(Function<? super PropertySet<T>,G> creator)
Build aGridwith columns auto-generated from introspected@GridColumnannotations, using the given function to instantiate theGrid.- Type Parameters:
G-Gridtype- Parameters:
creator- function that creates a newGridinstance given aPropertySet- Returns:
- new
Grid - Throws:
IllegalArgumentException- ifcreatoris null
-
getPropertyName
protected String getPropertyName(MethodAnnotationScanner.MethodInfo methodInfo)
Get the property name from the annotation.- Parameters:
methodInfo- method info- Returns:
- property name
-
getType
public Class<T> getType()
Get the type associated with this instance.- Returns:
- backing object type
-
getColumnMap
public Map<String,MethodAnnotationScanner.MethodInfo> getColumnMap()
Get the annotations found through introspection keyed by property name.- Returns:
- columns keyed by property name and sorted based on
GridColumn.order(), then property name
-
-