# HG changeset patch # User Sascha L. Teichmann # Date 1371209123 -7200 # Node ID c4fbd85a33eedd9182fc9bf405444beca617d4ed # Parent b2a470c148a7ee4fb0a5b609b901eec57043167a Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines. diff -r b2a470c148a7 -r c4fbd85a33ee backend/src/main/java/org/dive4elements/river/importer/ImportWst.java --- a/backend/src/main/java/org/dive4elements/river/importer/ImportWst.java Fri Jun 14 13:01:26 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportWst.java Fri Jun 14 13:25:23 2013 +0200 @@ -24,6 +24,18 @@ { private static Logger log = Logger.getLogger(ImportWst.class); + public interface ImportWstColumnFactory { + ImportWstColumn create(ImportWst iw, int position); + } + + public static final ImportWstColumnFactory COLUMN_FACTORY = + new ImportWstColumnFactory() { + @Override + public ImportWstColumn create(ImportWst importWst, int position) { + return new ImportWstColumn(importWst, null, null, position); + } + }; + protected String description; protected Integer kind; @@ -32,16 +44,27 @@ protected ImportUnit unit; + protected ImportWstColumnFactory columnFactory; + /** Wst as in db. */ protected Wst peer; public ImportWst() { + this(COLUMN_FACTORY); + } + + public ImportWst(ImportWstColumnFactory columnFactory) { + this.columnFactory = columnFactory; kind = 0; columns = new ArrayList(); } public ImportWst(String description) { - this(); + this(description, COLUMN_FACTORY); + } + + public ImportWst(String description, ImportWstColumnFactory columnFactory) { + this(columnFactory); this.description = description; } @@ -65,7 +88,7 @@ /** Create columns that can be accessed with getColumn. */ public void setNumberColumns(int numColumns) { for (int i = 0; i < numColumns; ++i) { - columns.add(new ImportWstColumn(this, null, null, i)); + columns.add(columnFactory.create(this, i)); } }