From 9f9b409b560fe5ea9d7f3330b1989c0842d8b8a4 Mon Sep 17 00:00:00 2001 From: Julien Lengrand-Lambert Date: Mon, 25 May 2020 22:45:32 +0200 Subject: [PATCH] Adds simple Javadoc --- .../lengrand/patterns/template/BinReportCreator.java | 4 ++++ .../nl/lengrand/patterns/template/BinaryFileMaker.java | 5 +++++ .../lengrand/patterns/template/CsvReportCreator.java | 4 ++++ .../nl/lengrand/patterns/template/ReportCreation.java | 10 ++++++++++ .../nl/lengrand/patterns/template/ReportCreator.java | 6 ++++++ 5 files changed, 29 insertions(+) diff --git a/src/main/java/nl/lengrand/patterns/template/BinReportCreator.java b/src/main/java/nl/lengrand/patterns/template/BinReportCreator.java index 11ad0e8..010a2ca 100644 --- a/src/main/java/nl/lengrand/patterns/template/BinReportCreator.java +++ b/src/main/java/nl/lengrand/patterns/template/BinReportCreator.java @@ -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 diff --git a/src/main/java/nl/lengrand/patterns/template/BinaryFileMaker.java b/src/main/java/nl/lengrand/patterns/template/BinaryFileMaker.java index 5df9daf..c65ca35 100644 --- a/src/main/java/nl/lengrand/patterns/template/BinaryFileMaker.java +++ b/src/main/java/nl/lengrand/patterns/template/BinaryFileMaker.java @@ -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 { diff --git a/src/main/java/nl/lengrand/patterns/template/CsvReportCreator.java b/src/main/java/nl/lengrand/patterns/template/CsvReportCreator.java index 38e62eb..64cebcf 100644 --- a/src/main/java/nl/lengrand/patterns/template/CsvReportCreator.java +++ b/src/main/java/nl/lengrand/patterns/template/CsvReportCreator.java @@ -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 diff --git a/src/main/java/nl/lengrand/patterns/template/ReportCreation.java b/src/main/java/nl/lengrand/patterns/template/ReportCreation.java index 5905da0..36b575a 100644 --- a/src/main/java/nl/lengrand/patterns/template/ReportCreation.java +++ b/src/main/java/nl/lengrand/patterns/template/ReportCreation.java @@ -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(); diff --git a/src/main/java/nl/lengrand/patterns/template/ReportCreator.java b/src/main/java/nl/lengrand/patterns/template/ReportCreator.java index 513ef24..8b2db6c 100644 --- a/src/main/java/nl/lengrand/patterns/template/ReportCreator.java +++ b/src/main/java/nl/lengrand/patterns/template/ReportCreator.java @@ -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 {