@Test public void testConfigEntriesFromStream() throws Exception { StringBuilder value = new StringBuilder(); value.append(TABLE_START); value.append("# random comment").append(LINE_SEP); value.append(LINE_SEP); value.append("dataClass=").append(Foo.class.getName()).append(LINE_SEP); String tableName = "fprwojfgopwejfw"; value.append("tableName=").append(tableName).append(LINE_SEP); value.append("# --table-fields-start--").append(LINE_SEP); value.append("# --field-start--").append(LINE_SEP); String fieldName = "weopjfwefjw"; value.append("fieldName=").append(fieldName).append(LINE_SEP); value.append("canBeNull=true").append(LINE_SEP); value.append("generatedId=true").append(LINE_SEP); value.append("# --field-end--").append(LINE_SEP); value.append("# --table-fields-end--").append(LINE_SEP); value.append(TABLE_END); List<DatabaseTableConfig<?>> tables = DatabaseTableConfigLoader.loadDatabaseConfigFromReader(new BufferedReader(new StringReader( value.toString()))); assertEquals(1, tables.size()); assertEquals(tableName, tables.get(0).getTableName()); DatabaseTableConfig<?> config = tables.get(0); List<DatabaseFieldConfig> fields = config.getFieldConfigs(); assertEquals(1, fields.size()); assertEquals(fieldName, fields.get(0).getFieldName()); }
public static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader) throws SQLException { List<DatabaseTableConfig<?>> list = new ArrayList<DatabaseTableConfig<?>>(); while (true) { DatabaseTableConfig<?> config = DatabaseTableConfigLoader.fromReader(reader); if (config == null) { break; } list.add(config); } return list; }
DatabaseTableConfigLoader { public static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader) throws SQLException { List<DatabaseTableConfig<?>> list = new ArrayList<DatabaseTableConfig<?>>(); while (true) { DatabaseTableConfig<?> config = DatabaseTableConfigLoader.fromReader(reader); if (config == null) { break; } list.add(config); } return list; } }
DatabaseTableConfigLoader { public static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader) throws SQLException { List<DatabaseTableConfig<?>> list = new ArrayList<DatabaseTableConfig<?>>(); while (true) { DatabaseTableConfig<?> config = DatabaseTableConfigLoader.fromReader(reader); if (config == null) { break; } list.add(config); } return list; }  }
DatabaseTableConfigLoader { public static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader) throws SQLException { List<DatabaseTableConfig<?>> list = new ArrayList<DatabaseTableConfig<?>>(); while (true) { DatabaseTableConfig<?> config = DatabaseTableConfigLoader.fromReader(reader); if (config == null) { break; } list.add(config); } return list; }  static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader); static DatabaseTableConfig<T> fromReader(BufferedReader reader); static void write(BufferedWriter writer, DatabaseTableConfig<T> config); }
DatabaseTableConfigLoader { public static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader) throws SQLException { List<DatabaseTableConfig<?>> list = new ArrayList<DatabaseTableConfig<?>>(); while (true) { DatabaseTableConfig<?> config = DatabaseTableConfigLoader.fromReader(reader); if (config == null) { break; } list.add(config); } return list; }  static List<DatabaseTableConfig<?>> loadDatabaseConfigFromReader(BufferedReader reader); static DatabaseTableConfig<T> fromReader(BufferedReader reader); static void write(BufferedWriter writer, DatabaseTableConfig<T> config);  }