For Grids using the LUMO theme there is an easy solution to get alternating row colors (look here under "Theme variants usage"). Furthermore if you know the number of grid columns you can set the colors using CSS selector vaadin-grid-cell-content:nth-child(an+b). But unfortunately both of these conditions are not met in our case.
How can one achieve alternating row colors in general cases?
The only solution I can come up with is using List input data and defining a row class generator as follows:
grid.setClassNameGenerator(i -> (entities.indexOf(i) % 2) == 0 ? "even-row" : "");
But I would like to use all types of Collection as input data.