Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### 2.1.7 (in progress)

- [improvement] Make NativeColumnType a top-level class (JAVA-715)
- [improvement] Unify "Target" enum for schema elements (JAVA-782)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public T addColumn(String columnName, DataType dataType) {
validateNotEmpty(columnName, "Column name");
validateNotNull(dataType, "Column type");
validateNotKeyWord(columnName, String.format("The column name '%s' is not allowed because it is a reserved keyword", columnName));
simpleColumns.put(columnName, new ColumnType.NativeColumnType(dataType));
simpleColumns.put(columnName, new NativeColumnType(dataType));
return self;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,4 @@
*/
interface ColumnType {
String asCQLString();

class NativeColumnType implements ColumnType {
private final String asCQLString;

NativeColumnType(DataType nativeType) {
asCQLString = nativeType.toString();
}

@Override public String asCQLString() {
return asCQLString;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Create addPartitionKey(String columnName, DataType dataType) {
validateNotEmpty(columnName, "Partition key name");
validateNotNull(dataType, "Partition key type");
validateNotKeyWord(columnName, String.format("The partition key name '%s' is not allowed because it is a reserved keyword", columnName));
partitionColumns.put(columnName, new ColumnType.NativeColumnType(dataType));
partitionColumns.put(columnName, new NativeColumnType(dataType));
return this;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ public Create addClusteringColumn(String columnName, DataType dataType) {
validateNotEmpty(columnName, "Clustering column name");
validateNotNull(dataType, "Clustering column type");
validateNotKeyWord(columnName, String.format("The clustering column name '%s' is not allowed because it is a reserved keyword", columnName));
clusteringColumns.put(columnName, new ColumnType.NativeColumnType(dataType));
clusteringColumns.put(columnName, new NativeColumnType(dataType));
return this;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ public Create addStaticColumn(String columnName, DataType dataType) {
validateNotEmpty(columnName, "Column name");
validateNotNull(dataType, "Column type");
validateNotKeyWord(columnName, String.format("The static column name '%s' is not allowed because it is a reserved keyword", columnName));
staticColumns.put(columnName, new ColumnType.NativeColumnType(dataType));
staticColumns.put(columnName, new NativeColumnType(dataType));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2012-2015 DataStax Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.datastax.driver.core.schemabuilder;

import com.datastax.driver.core.DataType;

/**
* Represents a native CQL type in a SchemaBuilder statement.
*/
class NativeColumnType implements ColumnType {
private final String asCQLString;

NativeColumnType(DataType nativeType) {
asCQLString = nativeType.toString();
}

@Override public String asCQLString() {
return asCQLString;
}
}