Which Factory Is It
abstract class ExportJob {
protected abstract Writer newWriter(OutputStream out);
public final void run(Query q, OutputStream out) {
Writer w = newWriter(out);
w.header(q.columns());
for (Row r : q.rows()) w.row(r);
w.close();
}
}
final class CsvExportJob extends ExportJob {
protected Writer newWriter(OutputStream out) { return new CsvWriter(out); }
}
final class ParquetExportJob extends ExportJob {
protected Writer newWriter(OutputStream out) { return new ParquetWriter(out); }
}
Which creational pattern is this, and what would have to change for it to become the other one it is usually confused with?
Sign in to answer questions and track your progress
Sign In