com.scalar.db.sql.common.metadata.ColumnMetadataImpl Maven / Gradle / Ivy
package com.scalar.db.sql.common.metadata;
import com.google.common.base.MoreObjects;
import com.scalar.db.sql.DataType;
import com.scalar.db.sql.metadata.ColumnMetadata;
import java.util.Objects;
import javax.annotation.concurrent.Immutable;
@Immutable
public class ColumnMetadataImpl implements ColumnMetadata {
private final String namespaceName;
private final String tableName;
private final String name;
private final DataType dataType;
private final boolean encrypted;
private ColumnMetadataImpl(
String namespaceName, String tableName, String name, DataType dataType, boolean encrypted) {
this.namespaceName = Objects.requireNonNull(namespaceName);
this.tableName = Objects.requireNonNull(tableName);
this.name = Objects.requireNonNull(name);
this.dataType = Objects.requireNonNull(dataType);
this.encrypted = encrypted;
}
@Override
public String getNamespaceName() {
return namespaceName;
}
@Override
public String getTableName() {
return tableName;
}
@Override
public String getName() {
return name;
}
@Override
public DataType getDataType() {
return dataType;
}
@Override
public boolean isEncrypted() {
return encrypted;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("namespaceName", namespaceName)
.add("tableName", tableName)
.add("name", name)
.add("dataType", dataType)
.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ColumnMetadataImpl)) {
return false;
}
ColumnMetadataImpl that = (ColumnMetadataImpl) o;
return Objects.equals(namespaceName, that.namespaceName)
&& Objects.equals(tableName, that.tableName)
&& Objects.equals(name, that.name)
&& dataType == that.dataType;
}
@Override
public int hashCode() {
return Objects.hash(namespaceName, tableName, name, dataType);
}
public static ColumnMetadata create(
String namespaceName, String tableName, String name, DataType dataType, boolean encrypted) {
return new ColumnMetadataImpl(namespaceName, tableName, name, dataType, encrypted);
}
}