com.scalar.db.sql.statement.CreateCoordinatorTablesStatement Maven / Gradle / Ivy
The newest version!
package com.scalar.db.sql.statement;
import com.google.common.collect.ImmutableMap;
import java.util.Objects;
import javax.annotation.concurrent.Immutable;
@Immutable
public class CreateCoordinatorTablesStatement implements DdlStatement {
public final boolean ifNotExist;
public final ImmutableMap options;
private CreateCoordinatorTablesStatement(
boolean ifNotExist, ImmutableMap options) {
this.ifNotExist = ifNotExist;
this.options = Objects.requireNonNull(options);
}
@Override
public String toSql() {
StringBuilder builder = new StringBuilder("CREATE COORDINATOR TABLES");
if (ifNotExist) {
builder.append(" IF NOT EXIST");
}
if (!options.isEmpty()) {
builder.append(" WITH ");
StatementUtils.appendOptions(builder, options);
}
return builder.toString();
}
@Override
public R accept(StatementVisitor visitor, C context) {
return visitor.visit(this, context);
}
@Override
public R accept(DdlStatementVisitor visitor, C context) {
return visitor.visit(this, context);
}
@Override
public String toString() {
return toSql();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CreateCoordinatorTablesStatement)) {
return false;
}
CreateCoordinatorTablesStatement that = (CreateCoordinatorTablesStatement) o;
return ifNotExist == that.ifNotExist && Objects.equals(options, that.options);
}
@Override
public int hashCode() {
return Objects.hash(ifNotExist, options);
}
public static CreateCoordinatorTablesStatement create(
boolean ifNotExist, ImmutableMap options) {
return new CreateCoordinatorTablesStatement(ifNotExist, options);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy