mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-13 08:15:20 +07:00
Added additional documentation to Table and refactored parser init function call
This commit is contained in:
parent
050f7dfc73
commit
2996e164f2
@ -41,8 +41,7 @@ public class Tables {
|
||||
static <R, T extends Table<R>>
|
||||
T loadTsv(T table, TsvParser parser) {
|
||||
parser.primaryKey(table.primaryKey());
|
||||
table.parser(parser);
|
||||
table.initialize();
|
||||
table.initialize(parser);
|
||||
return table;
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,16 @@ public abstract class Table<R> implements Iterable<R> {
|
||||
return ordered.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this table has been constructed and initialized. Used to
|
||||
* set-up table-specific configurations.
|
||||
*/
|
||||
protected void initialize() {}
|
||||
|
||||
/**
|
||||
* Assigns a record to a specified id. Implementations can override this and
|
||||
* call this super function to re-map indexes.
|
||||
*/
|
||||
protected void put(int id, R record) {
|
||||
records.put(id, record);
|
||||
ordered.add(record);
|
||||
@ -73,9 +81,14 @@ public abstract class Table<R> implements Iterable<R> {
|
||||
return parser;
|
||||
}
|
||||
|
||||
protected Parser<R> parser(ParserInput in) {
|
||||
/**
|
||||
* Initializes this table for loading records via a
|
||||
* {@link ParserInput parser}.
|
||||
*/
|
||||
protected final void initialize(ParserInput in) {
|
||||
if (parser != null) throw new IllegalStateException("parser already set");
|
||||
return this.parser = newParser(in).parseFields();
|
||||
this.parser = newParser(in).parseFields();
|
||||
initialize();
|
||||
}
|
||||
|
||||
public R get(int id) {
|
||||
|
Loading…
Reference in New Issue
Block a user