Add convenience addColumn method with ValueProvider and "RendererProvider"
Describe your motivation
The pattern used to add columns with renderers differs from that of those with values. Value columns require the use of a ValueProvider—typically expressed as a method reference or a lambda, whereas Renderer columns use an actual instance of the Renderer (which typically takes a ValueProvider as its constructor parameter).
It would seem natural for both to be able to use method references, where the one for the Renderer would be a renderer factory.
Describe the solution you'd like
I propose adding the following new method to Grid.
public <V> Grid.Column<T> addColumn(ValueProvider<T, V> valueProvider,
SerializableFunction<ValueProvider<T, V>, Renderer<T>> rendererFactory) {
return addColumn(rendererFactory.apply(valueProvider));
}
This additional method would allow the Grid, TreeGrid, and GridPro to all take advantage of this convenience method. (A corresponding addEditColumn method could also be added to GridPro.)
So, instead of writing something like:
grid.addColumn(Message::getPostUser);
grid.addColumn(new LocalDateTimeRenderer(Message::getPostDateTime));
grid.addColumn(Message::getHeading);
grid.addColumn(Message::getContent);
you could write:
grid.addColumn(Message::getPostUser);
grid.addColumn(Message::getPostDateTime, LocalDateTimeRenderer::new);
grid.addColumn(Message::getHeading);
grid.addColumn(Message::getContent);
where all the first parameters are method references for the properties.
Describe alternatives you've considered
None.
Additional context
No response