db.sql.api.impl.cmd.struct.From Maven / Gradle / Ivy
package db.sql.api.impl.cmd.struct;
import db.sql.api.Cmd;
import db.sql.api.SqlBuilderContext;
import db.sql.api.cmd.basic.IDataset;
import db.sql.api.cmd.basic.IDatasetField;
import db.sql.api.cmd.struct.IFrom;
import db.sql.api.impl.tookit.Lists;
import db.sql.api.impl.tookit.SqlConst;
import db.sql.api.tookit.CmdUtils;
import java.util.ArrayList;
import java.util.List;
public class From implements IFrom {
private final List tables = new ArrayList<>();
public , DATASET_FIELD extends IDatasetField> From append(DATASET... tables) {
Lists.merge(this.tables, tables);
return this;
}
@Override
public List getTables() {
return tables;
}
@Override
public StringBuilder sql(Cmd module, Cmd parent, SqlBuilderContext context, StringBuilder sqlBuilder) {
sqlBuilder.append(SqlConst.FROM);
return CmdUtils.join(module, this, context, sqlBuilder, this.tables, SqlConst.DELIMITER);
}
@Override
public boolean contain(Cmd cmd) {
return CmdUtils.contain(cmd, this.tables);
}
}