Class TableSpecification<T>

All Implemented Interfaces:
TableDescriptor
Direct Known Subclasses:
CreateTableSpecification

public class TableSpecification<T> extends TableOptionsSpecification<TableSpecification<T>> implements TableDescriptor
Object to support the configuration of table specifications that have columns. This class can also be used as a standalone TableDescriptor, independent of CreateTableSpecification.
Author:
Matthew T. Adams, Alex Shvid, Mark Paluch, Aleksei Zotov
  • Constructor Details

    • TableSpecification

      protected TableSpecification(com.datastax.oss.driver.api.core.CqlIdentifier name)
  • Method Details

    • column

      public T column(String name, com.datastax.oss.driver.api.core.type.DataType type)
      Adds the given non-key column to the table. Must be specified after all primary key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
    • column

      public T column(com.datastax.oss.driver.api.core.CqlIdentifier name, com.datastax.oss.driver.api.core.type.DataType type)
      Adds the given non-key column to the table. Must be specified after all primary key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
    • staticColumn

      public T staticColumn(String name, com.datastax.oss.driver.api.core.type.DataType type)
      Adds the given static column to the table. Must be specified after all primary key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      Since:
      3.2
    • staticColumn

      public T staticColumn(com.datastax.oss.driver.api.core.CqlIdentifier name, com.datastax.oss.driver.api.core.type.DataType type)
      Adds the given static column to the table. Must be specified after all primary key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      Since:
      3.2
    • partitionKeyColumn

      public T partitionKeyColumn(String name, com.datastax.oss.driver.api.core.type.DataType type)
      Adds the given partition key column to the table. Must be specified before any other columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      Returns:
      this
    • partitionKeyColumn

      public T partitionKeyColumn(com.datastax.oss.driver.api.core.CqlIdentifier name, com.datastax.oss.driver.api.core.type.DataType type)
      Adds the given partition key column to the table. Must be specified before any other columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      Returns:
      this
    • clusteredKeyColumn

      public T clusteredKeyColumn(String name, com.datastax.oss.driver.api.core.type.DataType type)
      Adds the given primary key column to the table with ascending ordering. Must be specified after all partition key columns and before any non-key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      Returns:
      this
    • clusteredKeyColumn

      public T clusteredKeyColumn(String name, com.datastax.oss.driver.api.core.type.DataType type, Ordering ordering)
      Adds the given primary key column to the table with ascending ordering. Must be specified after all partition key columns and before any non-key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      ordering - The data type of the column, must not be null.
      Returns:
      this
      Since:
      2.1
    • clusteredKeyColumn

      public T clusteredKeyColumn(com.datastax.oss.driver.api.core.CqlIdentifier name, com.datastax.oss.driver.api.core.type.DataType type)
      Adds the given primary key column to the table with ascending ordering. Must be specified after all partition key columns and before any non-key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      Returns:
      this
    • clusteredKeyColumn

      public T clusteredKeyColumn(com.datastax.oss.driver.api.core.CqlIdentifier name, com.datastax.oss.driver.api.core.type.DataType type, Ordering ordering)
      Adds the given primary key column to the table with ascending ordering. Must be specified after all partition key columns and before any non-key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      ordering - The data type of the column, must not be null.
      Returns:
      this
    • clusteredKeyColumn

      public T clusteredKeyColumn(com.datastax.oss.driver.api.core.CqlIdentifier name, com.datastax.oss.driver.api.core.type.DataType type, Optional<Ordering> ordering)
      Adds the given primary key column to the table with ascending ordering. Must be specified after all partition key columns and before any non-key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      ordering - The data type of the column, must not be null.
      Returns:
      this
    • column

      protected T column(String name, com.datastax.oss.driver.api.core.type.DataType type, PrimaryKeyType keyType)
      Adds the given info as a new column to the table. Partition key columns must precede primary key columns, which must precede non-key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      keyType - Indicates key type. Null means that the column is not a key column, must not be null.
      Returns:
      this
    • column

      protected T column(String name, com.datastax.oss.driver.api.core.type.DataType type, PrimaryKeyType keyType, Ordering ordering)
      Adds the given info as a new column to the table. Partition key columns must precede primary key columns, which must precede non-key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      keyType - Indicates key type, must not be null.
      ordering - If the given PrimaryKeyType is PrimaryKeyType.CLUSTERED, then the given ordering is used, else ignored, must not be null.
      Returns:
      this
    • column

      protected T column(String name, com.datastax.oss.driver.api.core.type.DataType type, PrimaryKeyType keyType, Optional<Ordering> ordering)
      Adds the given info as a new column to the table. Partition key columns must precede primary key columns, which must precede non-key columns.
      Parameters:
      name - The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes, must not be null.
      type - The data type of the column, must not be null.
      keyType - Indicates key type, must not be null.
      ordering - If the given PrimaryKeyType is PrimaryKeyType.CLUSTERED, then the given ordering is used, else ignored, must not be null.
      Returns:
      this
    • column

      protected T column(com.datastax.oss.driver.api.core.CqlIdentifier name, com.datastax.oss.driver.api.core.type.DataType type, Optional<PrimaryKeyType> optionalKeyType, Optional<Ordering> optionalOrdering, boolean isStatic)
    • getColumns

      public List<ColumnSpecification> getColumns()
      Returns an unmodifiable list of all columns.
      Specified by:
      getColumns in interface TableDescriptor
    • getPartitionKeyColumns

      public List<ColumnSpecification> getPartitionKeyColumns()
      Returns an unmodifiable list of all partition key columns.
      Specified by:
      getPartitionKeyColumns in interface TableDescriptor
    • getClusteredKeyColumns

      public List<ColumnSpecification> getClusteredKeyColumns()
      Returns an unmodifiable list of all primary key columns that are not also partition key columns.
      Specified by:
      getClusteredKeyColumns in interface TableDescriptor
    • getPrimaryKeyColumns

      public List<ColumnSpecification> getPrimaryKeyColumns()
      Returns an unmodifiable list of all primary key columns that are not also partition key columns.
      Specified by:
      getPrimaryKeyColumns in interface TableDescriptor
    • getNonKeyColumns

      public List<ColumnSpecification> getNonKeyColumns()
      Returns an unmodifiable list of all non-key columns.
      Specified by:
      getNonKeyColumns in interface TableDescriptor
    • getStaticColumns

      public List<ColumnSpecification> getStaticColumns()
      Returns an unmodifiable list of static columns.
      Specified by:
      getStaticColumns in interface TableDescriptor