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

liquibase.statement.core.UpdateStatement Maven / Gradle / Ivy

There is a newer version: 4.29.1
Show newest version
package liquibase.statement.core;

import liquibase.statement.AbstractSqlStatement;

import java.util.*;

public class UpdateStatement extends AbstractSqlStatement {
    private String catalogName;
    private String schemaName;
    private String tableName;
    private SortedMap newColumnValues = new TreeMap<>();
    private String whereClause;

    private List whereColumnNames = new ArrayList<>();
    private List whereParameters = new ArrayList<>();


    public UpdateStatement(String catalogName, String schemaName, String tableName) {
        this.catalogName = catalogName;
        this.schemaName = schemaName;
        this.tableName = tableName;
    }

    public String getCatalogName() {
        return catalogName;
    }

    public String getSchemaName() {
        return schemaName;
    }

    public String getTableName() {
        return tableName;
    }

    public UpdateStatement addNewColumnValue(String columnName, Object newValue) {
            newColumnValues.put(columnName, newValue);

        return this;
    }

    public String getWhereClause() {
        return whereClause;
    }

    public UpdateStatement setWhereClause(String whereClause) {
        this.whereClause = whereClause;

        return this;
    }

    public UpdateStatement addWhereParameter(Object value) {
        this.whereParameters.add(value);

        return this;
    }

    public UpdateStatement addWhereParameters(Object... value) {
        this.whereParameters.addAll(Arrays.asList(value));

        return this;
    }

    public UpdateStatement addWhereColumnName(String value) {
        this.whereColumnNames.add(value);

        return this;
    }


    public Map getNewColumnValues() {
        return newColumnValues;
    }

    public List getWhereParameters() {
        return whereParameters;
    }

    public List getWhereColumnNames() {
        return whereColumnNames;
    }
}