com.scalar.db.sql.statement.builder.AlterTableStatementBuilder Maven / Gradle / Ivy
package com.scalar.db.sql.statement.builder;
import com.scalar.db.sql.DataType;
import com.scalar.db.sql.TableRef;
import com.scalar.db.sql.statement.AlterTableAddColumnStatement;
import javax.annotation.Nullable;
public class AlterTableStatementBuilder {
private AlterTableStatementBuilder() {}
public static class Start {
@Nullable private final String namespaceName;
private final String tableName;
Start(@Nullable String namespaceName, String tableName) {
this.namespaceName = namespaceName;
this.tableName = tableName;
}
/**
* Adds a new column.
*
* @param columnName a column name to add
* @param columnDataType a column data type to add
* @return a builder object
*/
public AlterTableAddColumnStatementBuildable addColumn(
String columnName, DataType columnDataType) {
return new AlterTableAddColumnStatementBuildable(
namespaceName, tableName, columnName, columnDataType, false);
}
/**
* Adds a new column.
*
* @param columnName a column name to add
* @param columnDataType a column data type to add
* @param encrypted whether the column is encrypted
* @return a builder object
*/
public AlterTableAddColumnStatementBuildable addColumn(
String columnName, DataType columnDataType, boolean encrypted) {
return new AlterTableAddColumnStatementBuildable(
namespaceName, tableName, columnName, columnDataType, encrypted);
}
}
public static class AlterTableAddColumnStatementBuildable {
@Nullable private final String namespaceName;
private final String tableName;
private final String columnName;
private final DataType columnDataType;
private final boolean encrypted;
private AlterTableAddColumnStatementBuildable(
@Nullable String namespaceName,
String tableName,
String columnName,
DataType columnDataType,
boolean encrypted) {
this.namespaceName = namespaceName;
this.tableName = tableName;
this.columnName = columnName;
this.columnDataType = columnDataType;
this.encrypted = encrypted;
}
/**
* Builds a AlterTableAddColumnStatement object.
*
* @return a AlterTableAddColumnStatement object
*/
public AlterTableAddColumnStatement build() {
return AlterTableAddColumnStatement.create(
TableRef.of(namespaceName, tableName), columnName, columnDataType, encrypted);
}
}
}