@Test public void generateSql_threeGenerators() { SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator()); generators.add(new MockSqlGenerator(2, "B1", "B2")); generators.add(new MockSqlGenerator(1, "A1", "A2")); generators.add(new MockSqlGenerator(3, "C1", "C2")); SqlGeneratorChain chain = new SqlGeneratorChain(generators); Sql[] sql = chain.generateSql(new MockSqlStatement(), new MockDatabase()); assertEquals(6, sql.length); assertEquals("C1", sql[0].toSql()); assertEquals("C2", sql[1].toSql()); assertEquals("B1", sql[2].toSql()); assertEquals("B2", sql[3].toSql()); assertEquals("A1", sql[4].toSql()); assertEquals("A2", sql[5].toSql()); }
public Sql[] generateSql(SqlStatement statement, Database database) { if (sqlGenerators == null) { return null; } if (!sqlGenerators.hasNext()) { return new Sql[0]; } return sqlGenerators.next().generateSql(statement, database, this); }
SqlGeneratorChain { public Sql[] generateSql(SqlStatement statement, Database database) { if (sqlGenerators == null) { return null; } if (!sqlGenerators.hasNext()) { return new Sql[0]; } return sqlGenerators.next().generateSql(statement, database, this); } }
SqlGeneratorChain { public Sql[] generateSql(SqlStatement statement, Database database) { if (sqlGenerators == null) { return null; } if (!sqlGenerators.hasNext()) { return new Sql[0]; } return sqlGenerators.next().generateSql(statement, database, this); } SqlGeneratorChain(SortedSet<SqlGenerator> sqlGenerators); }
SqlGeneratorChain { public Sql[] generateSql(SqlStatement statement, Database database) { if (sqlGenerators == null) { return null; } if (!sqlGenerators.hasNext()) { return new Sql[0]; } return sqlGenerators.next().generateSql(statement, database, this); } SqlGeneratorChain(SortedSet<SqlGenerator> sqlGenerators); Sql[] generateSql(SqlStatement statement, Database database); Warnings warn(SqlStatement statement, Database database); ValidationErrors validate(SqlStatement statement, Database database); }
SqlGeneratorChain { public Sql[] generateSql(SqlStatement statement, Database database) { if (sqlGenerators == null) { return null; } if (!sqlGenerators.hasNext()) { return new Sql[0]; } return sqlGenerators.next().generateSql(statement, database, this); } SqlGeneratorChain(SortedSet<SqlGenerator> sqlGenerators); Sql[] generateSql(SqlStatement statement, Database database); Warnings warn(SqlStatement statement, Database database); ValidationErrors validate(SqlStatement statement, Database database);  }