All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liquibase.sqlgenerator.SqlGeneratorChain Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package liquibase.sqlgenerator;

import liquibase.database.Database;
import liquibase.exception.ValidationErrors;
import liquibase.exception.Warnings;
import liquibase.sql.Sql;
import liquibase.statement.SqlStatement;

import java.util.Iterator;
import java.util.SortedSet;

public class SqlGeneratorChain {
    private Iterator> sqlGenerators;

    public SqlGeneratorChain(SortedSet> sqlGenerators) {
        if (sqlGenerators != null) {
            this.sqlGenerators = sqlGenerators.iterator();
        }
    }

    public Sql[] generateSql(T statement, Database database) {
        if (sqlGenerators == null) {
            return null;
        }

        if (!sqlGenerators.hasNext()) {
            return new Sql[0];
        }

        return sqlGenerators.next().generateSql(statement, database, this);
    }

    public Warnings warn(T statement, Database database) {
        if ((sqlGenerators == null) || !sqlGenerators.hasNext()) {
            return new Warnings();
        }

        return sqlGenerators.next().warn(statement, database, this);
    }

    public ValidationErrors validate(T statement, Database database) {
        if ((sqlGenerators == null) || !sqlGenerators.hasNext()) {
            return new ValidationErrors();
        }

        return sqlGenerators.next().validate(statement, database, this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy