Get multiple Grid columns to apply a style

Is there a way to get multiple columns in a grid and do an operation on them with a single line of code?

For example, if you take the following lines of code:

grid.getColumn("maturityDate").setStyleGenerator(item -> "v-align-center"); grid.getColumn("valueDate").setStyleGenerator(item -> "v-align-center"); grid.getColumn("drawnDate").setStyleGenerator(item -> "v-align-center"); I would like to be able to reduce them down to something like:

grid.getColumns("maturityDate", "valueDate", drawnDate").setStyleGenerator(item -> "v-align-center");

Currently I can’t think of a way to do this, which means that I have a lot of lines of code that are effectively all doing a very similar thing, and would just like to be able to tidy them up.

I solved this problem using Java Streams. Not quite as direct as I would like, but it works.

Stream.of("maturityDate", "valueDate", "drawnDate").map(grid.getDefaultHeaderRow()::getCell)
    .forEach(cell -> cell.setStyleName("v-grid-header-align-center"));