25 lines
924 B
Java
25 lines
924 B
Java
package template;
|
|
|
|
/**
|
|
* Template Method Design Pattern — Runnable Demo
|
|
* Run: javac template/*.java -d out/template && java -cp out/template template.Main
|
|
* Article: https://ankurm.com/template-method-design-pattern-java/
|
|
*/
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
System.out.println("=== Template Method Design Pattern Demo ===");
|
|
|
|
DataMigration csvJob = new CsvMigration("customers_export.csv");
|
|
csvJob.migrate();
|
|
|
|
DataMigration apiJob = new ApiMigration("https://api.partner.com/v2/orders");
|
|
apiJob.migrate();
|
|
|
|
System.out.println("-- Both jobs used the same migrate() skeleton --");
|
|
System.out.println("-- Each provided its own connect/read/transform implementation --");
|
|
System.out.println("-- ApiMigration overrode the sendNotification() hook: no email --");
|
|
|
|
System.out.println("\n=== Demo complete ===");
|
|
}
|
|
}
|