Skip to content

Commit

Permalink
Added javadoc and removed some hardcoded, unused lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkhi committed Mar 12, 2024
1 parent fe16f4b commit 77e8d51
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public final class ExportDetails {
private final boolean quoteAllFields;
private final String columnsToWrite;
private final String exportTemplatePath;

/**
* Private constructor. The consumer can get the ExportDetails instance using the ExportDetailsBuilder.
* @param exportOptions whether it is a "per row" export or "per format" export
* @param outputEncoding encoding to be used
* @param bomFlag whether to use BOM
* @param quoteAllFields whether the export fields should be enclosed in double quotes
* @param columnsToWrite List of columns to write
* @param exportTemplatePath absolute path to an export template, if one is being used.
*/
private ExportDetails(ExportOptions exportOptions, String outputEncoding, boolean bomFlag, boolean quoteAllFields, String columnsToWrite, String exportTemplatePath) {
this.exportOptions = exportOptions;
this.outputEncoding = outputEncoding;
Expand Down Expand Up @@ -102,6 +112,9 @@ public String getExportTemplatePath() {
return exportTemplatePath;
}

/**
* Builder class to build the ExportDetails as a fluent API.
*/
public static class ExportDetailsBuilder {
private ExportOptions exportOptions = ExportOptions.ONE_ROW_PER_FILE;
private String outputEncoding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,15 @@
import java.util.HashMap;
import java.util.Map;

/**
* Implementation of ExportTemplate.
*/
public class ExportTemplateImpl implements ExportTemplate {
private final Map<Integer, ExportTemplateColumnDef> columnOrderMap = new HashMap<>();

//CHECKSTYLE:OFF - No need to worry about magic numbers here for now, until UI is all wired up
public ExportTemplateImpl() {
columnOrderMap.put(0, new ProfileResourceNodeColumnDef("ID", "Identifier"));
columnOrderMap.put(1, new ProfileResourceNodeColumnDef("FILE_PATH", "Path"));
columnOrderMap.put(2, new ProfileResourceNodeColumnDef("SIZE", "Size"));
columnOrderMap.put(3, new ProfileResourceNodeColumnDef("HASH", "HASH"));
columnOrderMap.put(4, new ProfileResourceNodeColumnDef("PUID", "Puid"));
columnOrderMap.put(5, new ConstantStringColumnDef("Welsh", "Language"));
columnOrderMap.put(6, new DataModifierColumnDef(new ProfileResourceNodeColumnDef("MIME_TYPE", "Mime Type"), ExportTemplateColumnDef.DataModification.UCASE));
}

public ExportTemplateImpl(final Map<Integer, ExportTemplateColumnDef> columnOrder) {
this.columnOrderMap.putAll(columnOrder);
}
//CHECKSTYLE:ON

public Map<Integer, ExportTemplateColumnDef> getColumnOrderMap() {
return columnOrderMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,13 @@ public void setExportTemplatePath(String exportTemplatePath) {
*/
private ExportDetails getExportDetails() {
ExportDetails.ExportDetailsBuilder builder = new ExportDetails.ExportDetailsBuilder();
ExportDetails details = builder.withExportOptions(options)
.withOutpuEncoding(outputEncoding) //default
return builder.withExportOptions(options)
.withOutpuEncoding(outputEncoding)
.withBomFlag(bom)
.withQuotingAllFields(quoteAllFields)
.withColumnsToWrite(columnsToWrite)
.withExportTemplatePath(exportTemplatePath)
.build();

return details;
}

}

0 comments on commit 77e8d51

Please sign in to comment.