mirror of
https://github.com/jlengrand/design-patterns.git
synced 2026-03-10 08:11:17 +00:00
Adds simple Javadoc
This commit is contained in:
@@ -7,6 +7,10 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This class extends from the template report creator, only implementing the logic to read a binary file
|
||||
* as input for a report
|
||||
*/
|
||||
public class BinReportCreator extends ReportCreator{
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,11 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
|
||||
/**
|
||||
* This file was just created to created the binary report that will be later read.
|
||||
* It is not part of the template method pattern
|
||||
*/
|
||||
public class BinaryFileMaker {
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This class extends from the template report creator, only implementing the logic to read a csv file
|
||||
* as input for a report
|
||||
*/
|
||||
public class CsvReportCreator extends ReportCreator {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,16 @@ package nl.lengrand.patterns.template;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* This class is here to demonstrate how to use the template method pattern.
|
||||
* Below, we are creating reports from a csv and a binary file.
|
||||
* Only a small part of the implementation is available to us, which allows to hide the complexity in a neat way.
|
||||
*
|
||||
* There is some boilerplate needed to find the files in the resource folder, but you can ignore that part
|
||||
*
|
||||
* The file being used to generate reports are in the resource folder, named template.csv and template.bin
|
||||
*/
|
||||
public class ReportCreation {
|
||||
public static void main(String[] args) throws IOException {
|
||||
ReportCreation reportCreation = new ReportCreation();
|
||||
|
||||
@@ -6,6 +6,12 @@ import java.util.InputMismatchException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* ReportCreator is our abstract template. It contains most of the boilerplate on how to create reports.
|
||||
* Most of the logic should be hidden from the end user (and the implementors). We need each type of report to extend
|
||||
* from ReportCreator so we can know how to read the input files
|
||||
*/
|
||||
public abstract class ReportCreator {
|
||||
|
||||
final void createReport(File filePath) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user