Skip to content

Commit c45e8c8

Browse files
committed
Make NativeColumnType a top-level class (JAVA-715).
1 parent eb5fb7f commit c45e8c8

5 files changed

Lines changed: 38 additions & 16 deletions

File tree

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### 2.1.7 (in progress)
44

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

78

driver-core/src/main/java/com/datastax/driver/core/schemabuilder/AbstractCreateStatement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public T addColumn(String columnName, DataType dataType) {
6868
validateNotEmpty(columnName, "Column name");
6969
validateNotNull(dataType, "Column type");
7070
validateNotKeyWord(columnName, String.format("The column name '%s' is not allowed because it is a reserved keyword", columnName));
71-
simpleColumns.put(columnName, new ColumnType.NativeColumnType(dataType));
71+
simpleColumns.put(columnName, new NativeColumnType(dataType));
7272
return self;
7373
}
7474

driver-core/src/main/java/com/datastax/driver/core/schemabuilder/ColumnType.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,4 @@
2626
*/
2727
interface ColumnType {
2828
String asCQLString();
29-
30-
class NativeColumnType implements ColumnType {
31-
private final String asCQLString;
32-
33-
NativeColumnType(DataType nativeType) {
34-
asCQLString = nativeType.toString();
35-
}
36-
37-
@Override public String asCQLString() {
38-
return asCQLString;
39-
}
40-
}
4129
}

driver-core/src/main/java/com/datastax/driver/core/schemabuilder/Create.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Create addPartitionKey(String columnName, DataType dataType) {
6666
validateNotEmpty(columnName, "Partition key name");
6767
validateNotNull(dataType, "Partition key type");
6868
validateNotKeyWord(columnName, String.format("The partition key name '%s' is not allowed because it is a reserved keyword", columnName));
69-
partitionColumns.put(columnName, new ColumnType.NativeColumnType(dataType));
69+
partitionColumns.put(columnName, new NativeColumnType(dataType));
7070
return this;
7171
}
7272

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

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2012-2015 DataStax Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.datastax.driver.core.schemabuilder;
17+
18+
import com.datastax.driver.core.DataType;
19+
20+
/**
21+
* Represents a native CQL type in a SchemaBuilder statement.
22+
*/
23+
class NativeColumnType implements ColumnType {
24+
private final String asCQLString;
25+
26+
NativeColumnType(DataType nativeType) {
27+
asCQLString = nativeType.toString();
28+
}
29+
30+
@Override public String asCQLString() {
31+
return asCQLString;
32+
}
33+
}

0 commit comments

Comments
 (0)