Class AbstractCreateStatement<T extends AbstractCreateStatement<T>>

    • Field Detail

      • ifNotExists

        protected boolean ifNotExists
      • simpleColumns

        protected Map<String,​com.datastax.driver.core.schemabuilder.ColumnType> simpleColumns
    • Constructor Detail

      • AbstractCreateStatement

        public AbstractCreateStatement()
    • Method Detail

      • ifNotExists

        public T ifNotExists()
        Add the 'IF NOT EXISTS' condition to this CREATE statement.
        Returns:
        this CREATE statement.
      • addColumn

        public T addColumn​(String columnName,
                           DataType dataType)
        Add a column definition to this CREATE statement.

        To add a list column:

        
         addColumn("myList",DataType.list(DataType.text()))
         

        To add a set column:

        
         addColumn("mySet",DataType.set(DataType.text()))
         

        To add a map column:

        
         addColumn("myMap",DataType.map(DataType.cint(),DataType.text()))
         
        Parameters:
        columnName - the name of the column to be added.
        dataType - the data type of the column to be added.
        Returns:
        this CREATE statement.
      • addUDTColumn

        public T addUDTColumn​(String columnName,
                              UDTType udtType)
        Add a column definition to this CREATE statement, when the type contains a UDT.
        Parameters:
        columnName - the name of the column to be added.
        udtType - the UDT type of the column to be added. Use SchemaBuilder.frozen(String) or SchemaBuilder.udtLiteral(String).
        Returns:
        this CREATE statement.
      • addUDTListColumn

        public T addUDTListColumn​(String columnName,
                                  UDTType udtType)
        Shorthand to add a column definition to this CREATE statement, when the type is a list of UDT.
        Parameters:
        columnName - the name of the column to be added
        udtType - the udt type of the column to be added. Use SchemaBuilder.frozen(String).
        Returns:
        this CREATE statement.
      • addUDTSetColumn

        public T addUDTSetColumn​(String columnName,
                                 UDTType udtType)
        Shorthand to add a column definition to this CREATE statement, when the type is a set of UDT.
        Parameters:
        columnName - the name of the column to be added
        udtType - the udt type of the column to be added. Use SchemaBuilder.frozen(String).
        Returns:
        this CREATE statement.
      • addUDTMapColumn

        public T addUDTMapColumn​(String columnName,
                                 DataType keyType,
                                 UDTType valueUdtType)
        Shorthand to add a column definition to this CREATE statement, when the type is a map with a UDT value type.

        Example:

             addUDTMapColumn("addresses", DataType.text(), frozen("address"));
         
        Parameters:
        columnName - the name of the column to be added.
        keyType - the key type of the column to be added.
        valueUdtType - the value UDT type of the column to be added. Use SchemaBuilder.frozen(String).
        Returns:
        this CREATE statement.
      • addUDTMapColumn

        public T addUDTMapColumn​(String columnName,
                                 UDTType udtKeyType,
                                 DataType valueType)
        Shorthand to add a column definition to this CREATE statement, when the type is a map with a UDT key type.

        Example:

             addUDTMapColumn("roles", frozen("user"), DataType.text());
         
        Parameters:
        columnName - the name of the column to be added.
        udtKeyType - the key UDT type of the column to be added. Use SchemaBuilder.frozen(String).
        valueType - the value raw type of the column to be added.
        Returns:
        this CREATE statement.
      • addUDTMapColumn

        public T addUDTMapColumn​(String columnName,
                                 UDTType udtKeyType,
                                 UDTType udtValueType)
        Shorthand to add a column definition to this CREATE statement, when the type is a map with UDT key and value types.

        Example:

             addUDTMapColumn("users", frozen("user"), frozen("address"));
         
        Parameters:
        columnName - the name of the column to be added.
        udtKeyType - the key UDT type of the column to be added. Use SchemaBuilder.frozen(String).
        udtValueType - the value UDT type of the column to be added. Use SchemaBuilder.frozen(String).
        Returns:
        this CREATE statement.
      • buildColumnType

        protected String buildColumnType​(Map.Entry<String,​com.datastax.driver.core.schemabuilder.ColumnType> entry)