Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small refactor of BaseStreamResourceWriter #142

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ abstract class BaseStreamResourceWriter<T> implements StreamResourceWriter {

private static final Logger LOGGER = LoggerFactory.getLogger(BaseStreamResourceWriter.class);

protected GridExporter<T> exporter;
protected String template;
protected final GridExporter<T> exporter;
private String template;

public BaseStreamResourceWriter(GridExporter<T> exporter) {
super();
Expand All @@ -63,6 +63,10 @@ public BaseStreamResourceWriter(
template = customTemplate == null ? defaultTemplate : customTemplate;
}

protected String getTemplate() {
return template;
}

/**
* If a column was configured to be exported or not, that will be honored. If not, it will
* exported based on the visibility
Expand Down Expand Up @@ -169,12 +173,12 @@ protected Stream<T> obtainDataStream(DataProvider<T, ?> dataProvider) {
return dataStream;
}

protected Stream<T> obtainFlattenedHierarchicalDataStream(final Grid<T> grid) {
private Stream<T> obtainFlattenedHierarchicalDataStream(final Grid<T> grid) {
ArrayList<T> flattenedData = fetchDataRecursive(grid, null);
return flattenedData.stream();
}

protected ArrayList<T> fetchDataRecursive(final Grid<T> grid, T parent) {
private ArrayList<T> fetchDataRecursive(final Grid<T> grid, T parent) {
ArrayList<T> result = new ArrayList<>();

if (parent != null) result.add(parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private XWPFTable findTable(XWPFDocument doc) {
}

private XWPFDocument getBaseTemplateDoc() throws EncryptedDocumentException, IOException {
InputStream inp = this.getClass().getResourceAsStream(template);
InputStream inp = this.getClass().getResourceAsStream(getTemplate());
return new XWPFDocument(inp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private void applyExcelFormat(Cell cell, String excelFormat, Map<String, CellSty

private Workbook getBaseTemplateWorkbook() {
try {
InputStream inp = this.getClass().getResourceAsStream(template);
InputStream inp = this.getClass().getResourceAsStream(getTemplate());
Workbook result = WorkbookFactory.create(inp);
return result;
} catch (Exception e) {
Expand Down
Loading