From c45e8c8b1cf0f609028182d0b05306689e5dae94 Mon Sep 17 00:00:00 2001 From: tommy stendahl Date: Thu, 4 Jun 2015 14:33:50 +0200 Subject: [PATCH] Make NativeColumnType a top-level class (JAVA-715). --- changelog/README.md | 1 + .../AbstractCreateStatement.java | 2 +- .../driver/core/schemabuilder/ColumnType.java | 12 ------- .../driver/core/schemabuilder/Create.java | 6 ++-- .../core/schemabuilder/NativeColumnType.java | 33 +++++++++++++++++++ 5 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 driver-core/src/main/java/com/datastax/driver/core/schemabuilder/NativeColumnType.java diff --git a/changelog/README.md b/changelog/README.md index 742f6576b4e..4f1d669598a 100644 --- a/changelog/README.md +++ b/changelog/README.md @@ -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) diff --git a/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/AbstractCreateStatement.java b/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/AbstractCreateStatement.java index 90e3501c181..7ecbc880c93 100644 --- a/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/AbstractCreateStatement.java +++ b/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/AbstractCreateStatement.java @@ -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; } diff --git a/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/ColumnType.java b/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/ColumnType.java index 4babf399bfb..4e1eeef76a4 100644 --- a/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/ColumnType.java +++ b/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/ColumnType.java @@ -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; - } - } } diff --git a/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/Create.java b/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/Create.java index f6b7fa5a339..b56a4a548de 100755 --- a/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/Create.java +++ b/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/Create.java @@ -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; } @@ -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; } @@ -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; } diff --git a/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/NativeColumnType.java b/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/NativeColumnType.java new file mode 100644 index 00000000000..f05df756023 --- /dev/null +++ b/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/NativeColumnType.java @@ -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; + } +}