com.scalar.db.storage.cosmos.CosmosTableMetadata Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalardb Show documentation
Show all versions of scalardb Show documentation
A universal transaction manager that achieves database-agnostic transactions and distributed transactions that span multiple databases
package com.scalar.db.storage.cosmos;
import com.google.common.base.MoreObjects;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.annotation.concurrent.NotThreadSafe;
/**
* A metadata class for a table of ScalarDB to know the type of each column
*
* @author Yuji Ito
*/
@SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
@NotThreadSafe
public class CosmosTableMetadata {
private String id;
private LinkedHashSet partitionKeyNames;
private LinkedHashSet clusteringKeyNames;
private Map clusteringOrders;
private Set secondaryIndexNames;
private Map columns;
public CosmosTableMetadata() {}
public void setId(String id) {
this.id = id;
}
public void setPartitionKeyNames(List partitionKeyNames) {
this.partitionKeyNames = new LinkedHashSet<>(partitionKeyNames);
}
public void setClusteringKeyNames(List clusteringKeyNames) {
this.clusteringKeyNames = new LinkedHashSet<>(clusteringKeyNames);
}
public void setClusteringOrders(Map clusteringOrders) {
this.clusteringOrders = clusteringOrders;
}
public void setSecondaryIndexNames(Set secondaryIndexNames) {
this.secondaryIndexNames = secondaryIndexNames;
}
public void setColumns(Map columns) {
this.columns = columns;
}
public String getId() {
return id;
}
public LinkedHashSet getPartitionKeyNames() {
return partitionKeyNames;
}
public LinkedHashSet getClusteringKeyNames() {
return clusteringKeyNames;
}
public Map getClusteringOrders() {
return clusteringOrders;
}
public Set getSecondaryIndexNames() {
return secondaryIndexNames;
}
public Map getColumns() {
return columns;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CosmosTableMetadata)) {
return false;
}
CosmosTableMetadata that = (CosmosTableMetadata) o;
return Objects.equals(id, that.id)
&& Objects.equals(partitionKeyNames, that.partitionKeyNames)
&& Objects.equals(clusteringKeyNames, that.clusteringKeyNames)
&& Objects.equals(clusteringOrders, that.clusteringOrders)
&& Objects.equals(secondaryIndexNames, that.secondaryIndexNames)
&& Objects.equals(columns, that.columns);
}
@Override
public int hashCode() {
return Objects.hash(
id, partitionKeyNames, clusteringKeyNames, clusteringOrders, secondaryIndexNames, columns);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("partitionKeyNames", partitionKeyNames)
.add("clusteringKeyNames", clusteringKeyNames)
.add("clusteringOrders", clusteringOrders)
.add("secondaryIndexNames", secondaryIndexNames)
.add("columns", columns)
.toString();
}
}