@Test
public void alternatingRows() throws IOException {

  OutputStream baos = new ByteArrayOutputStream();
  ElementCreator elementCreator =
      (elementName, column, row) -> {
        Element element = new Element(elementName);
        if (elementName.equals("tr") && row != null) {
          return element.addClass(row % 2 == 0 ? "even" : "odd");
        }
        return element;
      };
  table
      .write()
      .usingOptions(HtmlWriteOptions.builder(baos).elementCreator(elementCreator).build());
  String output = baos.toString();
  assertEquals(
      "<table>"
          + LINE_END
          + " <thead>"
          + LINE_END
          + "  <tr>"
          + LINE_END
          + "   <th>v</th>"
          + LINE_END
          + "   <th>v2</th>"
          + LINE_END
          + "  </tr>"
          + LINE_END
          + " </thead>"
          + LINE_END
          + " <tbody>"
          + LINE_END
          + "  <tr class=\"even\">"
          + LINE_END
          + "   <td>1</td>"
          + LINE_END
          + "   <td>1</td>"
          + LINE_END
          + "  </tr>"
          + LINE_END
          + "  <tr class=\"odd\">"
          + LINE_END
          + "   <td>2</td>"
          + LINE_END
          + "   <td>2</td>"
          + LINE_END
          + "  </tr>"
          + LINE_END
          + "  <tr class=\"even\">"
          + LINE_END
          + "   <td></td>"
          + LINE_END
          + "   <td></td>"
          + LINE_END
          + "  </tr>"
          + LINE_END
          + " </tbody>"
          + LINE_END
          + "</table>",
      output);
}