Class AbstractCreateStatement<T extends AbstractCreateStatement<T>>
- java.lang.Object
-
- com.datastax.driver.core.Statement
-
- com.datastax.driver.core.RegularStatement
-
- com.datastax.driver.core.schemabuilder.SchemaStatement
-
- com.datastax.driver.core.schemabuilder.AbstractCreateStatement<T>
-
- Direct Known Subclasses:
Create,CreateType
public abstract class AbstractCreateStatement<T extends AbstractCreateStatement<T>> extends SchemaStatement
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanifNotExistsprotected Optional<String>keyspaceNameprotected Map<String,com.datastax.driver.core.schemabuilder.ColumnType>simpleColumns-
Fields inherited from class com.datastax.driver.core.Statement
idempotent, NULL_PAYLOAD_VALUE
-
-
Constructor Summary
Constructors Constructor Description AbstractCreateStatement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TaddColumn(String columnName, DataType dataType)Add a column definition to this CREATE statement.TaddUDTColumn(String columnName, UDTType udtType)Add a column definition to this CREATE statement, when the type contains a UDT.TaddUDTListColumn(String columnName, UDTType udtType)Shorthand to add a column definition to this CREATE statement, when the type is a list of UDT.TaddUDTMapColumn(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.TaddUDTMapColumn(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.TaddUDTMapColumn(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.TaddUDTSetColumn(String columnName, UDTType udtType)Shorthand to add a column definition to this CREATE statement, when the type is a set of UDT.protected StringbuildColumnType(Map.Entry<String,com.datastax.driver.core.schemabuilder.ColumnType> entry)TifNotExists()Add the 'IF NOT EXISTS' condition to this CREATE statement.-
Methods inherited from class com.datastax.driver.core.schemabuilder.SchemaStatement
getKeyspace, getNamedValues, getQueryString, getRoutingKey, getValues, hasValues, usesNamedValues
-
Methods inherited from class com.datastax.driver.core.RegularStatement
getQueryString, hasValues, requestSizeInBytes, toString
-
Methods inherited from class com.datastax.driver.core.Statement
disableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getHost, getLastHost, getNowInSeconds, getOutgoingPayload, getPartitioner, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, isBatchIdempotent, isIdempotent, isLWT, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setHost, setIdempotent, setLastHost, setNowInSeconds, setOutgoingPayload, setPagingState, setPagingState, setPagingStateUnsafe, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel
-
-
-
-
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. UseSchemaBuilder.frozen(String)orSchemaBuilder.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 addedudtType- the udt type of the column to be added. UseSchemaBuilder.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 addedudtType- the udt type of the column to be added. UseSchemaBuilder.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. UseSchemaBuilder.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. UseSchemaBuilder.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. UseSchemaBuilder.frozen(String).udtValueType- the value UDT type of the column to be added. UseSchemaBuilder.frozen(String).- Returns:
- this CREATE statement.
-
-