Class ColumnSpecification

java.lang.Object
org.springframework.data.cassandra.core.cql.keyspace.ColumnSpecification

public class ColumnSpecification extends Object
Object to configure a CQL column specification.

Use name(String) and type(DataType) to set the name and type of the column, respectively. To specify a clustered PRIMARY KEY column, use clustered() or clustered(Ordering). To specify that the PRIMARY KEY column is or is part of the partition key, use partitioned() instead of clustered() or clustered(Ordering). To specify STATIC column, use staticColumn().

Author:
Matthew T. Adams, Alex Shvid, Mark Paluch, Aleksei Zotov
  • Field Details

    • DEFAULT_ORDERING

      public static final Ordering DEFAULT_ORDERING
      Default ordering of primary key fields; value is Ordering.ASCENDING.
  • Method Details

    • name

      public static ColumnSpecification name(String name)
      Create a new ColumnSpecification for the given name.
      Parameters:
      name - must not be null or empty.
      Returns:
      a new ColumnSpecification for name.
    • name

      public static ColumnSpecification name(com.datastax.oss.driver.api.core.CqlIdentifier name)
      Create a new ColumnSpecification for the given name.
      Parameters:
      name - must not be null.
      Returns:
      a new ColumnSpecification for name.
    • type

      public ColumnSpecification type(com.datastax.oss.driver.api.core.type.DataType type)
      Sets the column's type.
      Returns:
      this
    • partitioned

      public ColumnSpecification partitioned()
      Identifies this column as a primary key column that is also part of a partition key. Sets the column's keyType to PrimaryKeyType.PARTITIONED and its ordering to null.
      Returns:
      this
    • partitioned

      public ColumnSpecification partitioned(boolean partitioned)
      Toggles the identification of this column as a primary key column that also is or is part of a partition key. Sets ordering to null and, if the given boolean is true, then sets the column's keyType to PrimaryKeyType.PARTITIONED, else sets it to null.
      Returns:
      this
    • clustered

      public ColumnSpecification clustered()
      Identifies this column as a clustered key column with default ordering. Sets the column's keyType to PrimaryKeyType.CLUSTERED and its ordering to DEFAULT_ORDERING.
      Returns:
      this
    • clustered

      public ColumnSpecification clustered(Ordering order)
      Identifies this column as a clustered key column with the given ordering. Sets the column's keyType to PrimaryKeyType.CLUSTERED and its ordering to the given Ordering.
      Returns:
      this
    • clustered

      public ColumnSpecification clustered(Ordering order, boolean primary)
      Toggles the identification of this column as a clustered key column. If the given boolean is true, then sets the column's keyType to PrimaryKeyType.PARTITIONED and ordering to the given Ordering , else sets both keyType and ordering to null.
      Returns:
      this
    • keyType

      public ColumnSpecification keyType(PrimaryKeyType keyType)
      Sets the column's keyType.
      Returns:
      this
    • ordering

      public ColumnSpecification ordering(Ordering ordering)
      Sets the column's ordering.
      Returns:
      this
    • staticColumn

      public ColumnSpecification staticColumn()
      Identifies this column as a static column. Sets the column's isStatic to true.
      Returns:
      this
      Since:
      3.2
    • getName

      public com.datastax.oss.driver.api.core.CqlIdentifier getName()
    • getType

      @Nullable public com.datastax.oss.driver.api.core.type.DataType getType()
    • getKeyType

      @Nullable public PrimaryKeyType getKeyType()
    • getOrdering

      @Nullable public Ordering getOrdering()
    • isStatic

      public boolean isStatic()
    • toCql

      public String toCql()
    • toCql

      public StringBuilder toCql(StringBuilder cql)
    • toString

      public String toString()
      Overrides:
      toString in class Object