@Test(expected = Exception.class) public void extendHorizontallyNullMatrix() throws Exception { DataSection section = mock(DataSection.class); StyleOption style = StyleOption.SECTION_BORDER_LEFT; doReturn(null).when(section).getMatrix(); Styler.extendStyleHorizontally(section, style); verifyNoMoreInteractions(section); }
@SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) public static void extendStyleHorizontally(DataSection section, StyleOption... styles) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { Set<StyleOption> toExtend = new HashSet<>(); Integer startingX = 0; Boolean found = false; for (int x = 0; x <= section.getMaxX(); x++) { found = false; DataCell cell = cellMatrix[x][y]; if (cell == null) { continue; } for (StyleOption style : styles) { if (cell.getStyles() != null && cell.getStyles().contains(style)) { toExtend.add(style); found = true; } } if (found) { startingX = x; break; } } if (!found) { continue; } for (int x = startingX + 1; x <= section.getMaxX(); x++) { DataCell cell = cellMatrix[x][y]; if (cell == null) { cell = new DataCell("", x, y); section.addCell(cell); } cell.addStyles(toExtend); } } }
Styler { @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) public static void extendStyleHorizontally(DataSection section, StyleOption... styles) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { Set<StyleOption> toExtend = new HashSet<>(); Integer startingX = 0; Boolean found = false; for (int x = 0; x <= section.getMaxX(); x++) { found = false; DataCell cell = cellMatrix[x][y]; if (cell == null) { continue; } for (StyleOption style : styles) { if (cell.getStyles() != null && cell.getStyles().contains(style)) { toExtend.add(style); found = true; } } if (found) { startingX = x; break; } } if (!found) { continue; } for (int x = startingX + 1; x <= section.getMaxX(); x++) { DataCell cell = cellMatrix[x][y]; if (cell == null) { cell = new DataCell("", x, y); section.addCell(cell); } cell.addStyles(toExtend); } } } }
Styler { @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) public static void extendStyleHorizontally(DataSection section, StyleOption... styles) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { Set<StyleOption> toExtend = new HashSet<>(); Integer startingX = 0; Boolean found = false; for (int x = 0; x <= section.getMaxX(); x++) { found = false; DataCell cell = cellMatrix[x][y]; if (cell == null) { continue; } for (StyleOption style : styles) { if (cell.getStyles() != null && cell.getStyles().contains(style)) { toExtend.add(style); found = true; } } if (found) { startingX = x; break; } } if (!found) { continue; } for (int x = startingX + 1; x <= section.getMaxX(); x++) { DataCell cell = cellMatrix[x][y]; if (cell == null) { cell = new DataCell("", x, y); section.addCell(cell); } cell.addStyles(toExtend); } } }  }
Styler { @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) public static void extendStyleHorizontally(DataSection section, StyleOption... styles) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { Set<StyleOption> toExtend = new HashSet<>(); Integer startingX = 0; Boolean found = false; for (int x = 0; x <= section.getMaxX(); x++) { found = false; DataCell cell = cellMatrix[x][y]; if (cell == null) { continue; } for (StyleOption style : styles) { if (cell.getStyles() != null && cell.getStyles().contains(style)) { toExtend.add(style); found = true; } } if (found) { startingX = x; break; } } if (!found) { continue; } for (int x = startingX + 1; x <= section.getMaxX(); x++) { DataCell cell = cellMatrix[x][y]; if (cell == null) { cell = new DataCell("", x, y); section.addCell(cell); } cell.addStyles(toExtend); } } }  static void disallowBodyStyles(DataSection section); static void styleSectionBottom(DataSection section, StyleOption style); static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight); @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) static void extendStyleHorizontally(DataSection section, StyleOption... styles); @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) static void extendStyleVertically(DataSection section, StyleOption... styles); void style(DataCell dataCell, Cell cell, Workbook wBook); }
Styler { @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) public static void extendStyleHorizontally(DataSection section, StyleOption... styles) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { Set<StyleOption> toExtend = new HashSet<>(); Integer startingX = 0; Boolean found = false; for (int x = 0; x <= section.getMaxX(); x++) { found = false; DataCell cell = cellMatrix[x][y]; if (cell == null) { continue; } for (StyleOption style : styles) { if (cell.getStyles() != null && cell.getStyles().contains(style)) { toExtend.add(style); found = true; } } if (found) { startingX = x; break; } } if (!found) { continue; } for (int x = startingX + 1; x <= section.getMaxX(); x++) { DataCell cell = cellMatrix[x][y]; if (cell == null) { cell = new DataCell("", x, y); section.addCell(cell); } cell.addStyles(toExtend); } } }  static void disallowBodyStyles(DataSection section); static void styleSectionBottom(DataSection section, StyleOption style); static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight); @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) static void extendStyleHorizontally(DataSection section, StyleOption... styles); @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) static void extendStyleVertically(DataSection section, StyleOption... styles); void style(DataCell dataCell, Cell cell, Workbook wBook);  }