package dao;

import java.util.List;

public class UpdateAll extends SQLStmt {
    private static final String fs ="UPDATE ";
    List<String> fields;
    String increment;

    public UpdateAll(String table, List<String> fields, String increment) {
        super(table);
        this.setFields(fields);
        this.setIncrement(increment);
    }

    @Override
    public String getSQL() {
        return this.getFs()+this.getUs();
    }

    @Override
    public String getFs() {
        return fs+this.getTable()+" ";
    }
    public String getUs(){
        String us = "SET ";
        for(String s:this.getFields()){
            us+=s+" = "+s+" + "+this.getIncrement()+", ";
        }
        return utils.Utils.cutTail(us,2);
    }

    public List<String> getFields() {
        return fields;
    }

    public void setFields(List<String> fields) {
        this.fields = fields;
    }

    public String getIncrement() {
        return increment;
    }

    public void setIncrement(String increment) {
        this.increment = increment;
    }
}
