com.scalar.db.sql.statement.UseStatement Maven / Gradle / Ivy
package com.scalar.db.sql.statement;
import java.util.Objects;
import javax.annotation.concurrent.Immutable;
@Immutable
public class UseStatement implements CommandStatement {
public final String namespaceName;
private UseStatement(String namespaceName) {
this.namespaceName = Objects.requireNonNull(namespaceName);
}
@Override
public String toSql() {
StringBuilder builder = new StringBuilder("USE ");
StatementUtils.appendObjectName(builder, namespaceName);
return builder.toString();
}
@Override
public R accept(CommandStatementVisitor visitor, C context) {
return visitor.visit(this, context);
}
@Override
public R accept(StatementVisitor 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 UseStatement)) {
return false;
}
UseStatement that = (UseStatement) o;
return Objects.equals(namespaceName, that.namespaceName);
}
@Override
public int hashCode() {
return Objects.hash(namespaceName);
}
public static UseStatement create(String namespaceName) {
return new UseStatement(namespaceName);
}
}