type)
.collect(Collectors.toList());
}
- private ASTTreeUtils() {}
+ private AstTreeUtils() {}
/**
* Generate the original parsed text between the 2 specified tokens, normalizing the text with
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/diff/ConstraintWrapper.java b/src/main/java/com/google/cloud/solutions/spannerddl/diff/ConstraintWrapper.java
new file mode 100644
index 0000000..3d9e65c
--- /dev/null
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/diff/ConstraintWrapper.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2024 Google LLC
+ *
+ * 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
+ *
+ * https://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.google.cloud.solutions.spannerddl.diff;
+
+import com.google.auto.value.AutoValue;
+import com.google.cloud.solutions.spannerddl.parser.ASTcheck_constraint;
+import com.google.cloud.solutions.spannerddl.parser.ASTforeign_key;
+import com.google.cloud.solutions.spannerddl.parser.SimpleNode;
+
+/**
+ * Wrapper class for Check and Foreign Key constraints to include the table name for when they are
+ * separated from their create table/alter table statements in
+ * separateTablesIndexesConstraintsTtls().
+ */
+@AutoValue
+abstract class ConstraintWrapper {
+
+ static ConstraintWrapper create(String tableName, SimpleNode constraint) {
+ if (!(constraint instanceof ASTforeign_key) && !(constraint instanceof ASTcheck_constraint)) {
+ throw new IllegalArgumentException("not a valid constraint type : " + constraint.toString());
+ }
+ return new AutoValue_ConstraintWrapper(tableName, constraint);
+ }
+
+ abstract String tableName();
+
+ abstract SimpleNode constraint();
+
+ String getName() {
+ if (constraint() instanceof ASTcheck_constraint) {
+ return ((ASTcheck_constraint) constraint()).getName();
+ }
+ if (constraint() instanceof ASTforeign_key) {
+ return ((ASTforeign_key) constraint()).getName();
+ }
+ throw new IllegalArgumentException("not a valid constraint type : " + constraint().toString());
+ }
+}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/diff/DatbaseDefinition.java b/src/main/java/com/google/cloud/solutions/spannerddl/diff/DatbaseDefinition.java
new file mode 100644
index 0000000..d1e2673
--- /dev/null
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/diff/DatbaseDefinition.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2024 Google LLC
+ *
+ * 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
+ *
+ * https://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.google.cloud.solutions.spannerddl.diff;
+
+import com.google.auto.value.AutoValue;
+import com.google.cloud.solutions.spannerddl.parser.ASTadd_row_deletion_policy;
+import com.google.cloud.solutions.spannerddl.parser.ASTalter_database_statement;
+import com.google.cloud.solutions.spannerddl.parser.ASTalter_table_statement;
+import com.google.cloud.solutions.spannerddl.parser.ASTcheck_constraint;
+import com.google.cloud.solutions.spannerddl.parser.ASTcreate_change_stream_statement;
+import com.google.cloud.solutions.spannerddl.parser.ASTcreate_index_statement;
+import com.google.cloud.solutions.spannerddl.parser.ASTcreate_table_statement;
+import com.google.cloud.solutions.spannerddl.parser.ASTddl_statement;
+import com.google.cloud.solutions.spannerddl.parser.ASTforeign_key;
+import com.google.cloud.solutions.spannerddl.parser.ASTrow_deletion_policy_clause;
+import com.google.cloud.solutions.spannerddl.parser.DdlParserTreeConstants;
+import com.google.cloud.solutions.spannerddl.parser.SimpleNode;
+import com.google.common.collect.ImmutableMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Separarates the different DDL creation statements into separate maps.
+ *
+ * Constraints which were created inline with their table are separated into a map with any other
+ * ALTER statements which adds constraints.
+ *
+ *
This allows the diff tool to handle these objects which are created inline with the table in
+ * the same way as if they were created separately with ALTER statements.
+ */
+@AutoValue
+abstract class DatbaseDefinition {
+ static DatbaseDefinition create(List statements) {
+ // Use LinkedHashMap to preserve creation order in original DDL.
+ LinkedHashMap tablesInCreationOrder = new LinkedHashMap<>();
+ LinkedHashMap indexes = new LinkedHashMap<>();
+ LinkedHashMap constraints = new LinkedHashMap<>();
+ LinkedHashMap ttls = new LinkedHashMap<>();
+ LinkedHashMap changeStreams = new LinkedHashMap<>();
+ LinkedHashMap alterDatabaseOptions = new LinkedHashMap<>();
+
+ for (ASTddl_statement ddlStatement : statements) {
+ final SimpleNode statement = (SimpleNode) ddlStatement.jjtGetChild(0);
+
+ switch (statement.getId()) {
+ case DdlParserTreeConstants.JJTCREATE_TABLE_STATEMENT:
+ ASTcreate_table_statement createTable = (ASTcreate_table_statement) statement;
+ // Remove embedded constraint statements from the CreateTable node
+ // as they are taken into account via `constraints`
+ tablesInCreationOrder.put(createTable.getTableName(), createTable.clearConstraints());
+
+ // convert embedded constraint statements into wrapper object with table name
+ // use a single map for all foreign keys, constraints and row deletion polcies whether
+ // created in table or externally
+ createTable.getConstraints().values().stream()
+ .map(c -> ConstraintWrapper.create(createTable.getTableName(), c))
+ .forEach(c -> constraints.put(c.getName(), c));
+
+ // Move embedded Row Deletion Policies
+ final Optional rowDeletionPolicyClause =
+ createTable.getRowDeletionPolicyClause();
+ rowDeletionPolicyClause.ifPresent(rdp -> ttls.put(createTable.getTableName(), rdp));
+ break;
+ case DdlParserTreeConstants.JJTCREATE_INDEX_STATEMENT:
+ indexes.put(
+ ((ASTcreate_index_statement) statement).getIndexName(),
+ (ASTcreate_index_statement) statement);
+ break;
+ case DdlParserTreeConstants.JJTALTER_TABLE_STATEMENT:
+ // Alter table can be adding Index, Constraint or Row Deletion Policy
+ ASTalter_table_statement alterTable = (ASTalter_table_statement) statement;
+ final String tableName = alterTable.jjtGetChild(0).toString();
+
+ if (alterTable.jjtGetChild(1) instanceof ASTforeign_key
+ || alterTable.jjtGetChild(1) instanceof ASTcheck_constraint) {
+ ConstraintWrapper constraint =
+ ConstraintWrapper.create(tableName, (SimpleNode) alterTable.jjtGetChild(1));
+ constraints.put(constraint.getName(), constraint);
+
+ } else if (statement.jjtGetChild(1) instanceof ASTadd_row_deletion_policy) {
+ ttls.put(
+ tableName,
+ (ASTrow_deletion_policy_clause) alterTable.jjtGetChild(1).jjtGetChild(0));
+ } else {
+ // other ALTER statements are not supported.
+ throw new IllegalArgumentException(
+ "Unsupported ALTER TABLE statement: " + AstTreeUtils.tokensToString(ddlStatement));
+ }
+ break;
+ case DdlParserTreeConstants.JJTALTER_DATABASE_STATEMENT:
+ alterDatabaseOptions.putAll(
+ ((ASTalter_database_statement) statement).getOptionsClause().getKeyValueMap());
+ break;
+ case DdlParserTreeConstants.JJTCREATE_CHANGE_STREAM_STATEMENT:
+ changeStreams.put(
+ ((ASTcreate_change_stream_statement) statement).getName(),
+ (ASTcreate_change_stream_statement) statement);
+ break;
+ default:
+ throw new IllegalArgumentException(
+ "Unsupported statement: " + AstTreeUtils.tokensToString(ddlStatement));
+ }
+ }
+ return new AutoValue_DatbaseDefinition(
+ ImmutableMap.copyOf(tablesInCreationOrder),
+ ImmutableMap.copyOf(indexes),
+ ImmutableMap.copyOf(constraints),
+ ImmutableMap.copyOf(ttls),
+ ImmutableMap.copyOf(changeStreams),
+ ImmutableMap.copyOf(alterDatabaseOptions));
+ }
+
+ abstract ImmutableMap tablesInCreationOrder();
+
+ abstract ImmutableMap indexes();
+
+ abstract ImmutableMap constraints();
+
+ abstract ImmutableMap ttls();
+
+ abstract ImmutableMap changeStreams();
+
+ abstract ImmutableMap alterDatabaseOptions();
+}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiff.java b/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiff.java
index c22dee5..6b9ce36 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiff.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiff.java
@@ -18,7 +18,6 @@
import static java.nio.charset.StandardCharsets.UTF_8;
-import com.google.auto.value.AutoValue;
import com.google.cloud.solutions.spannerddl.parser.ASTadd_row_deletion_policy;
import com.google.cloud.solutions.spannerddl.parser.ASTalter_database_statement;
import com.google.cloud.solutions.spannerddl.parser.ASTalter_table_statement;
@@ -36,13 +35,11 @@
import com.google.cloud.solutions.spannerddl.parser.DdlParser;
import com.google.cloud.solutions.spannerddl.parser.DdlParserTreeConstants;
import com.google.cloud.solutions.spannerddl.parser.ParseException;
-import com.google.cloud.solutions.spannerddl.parser.SimpleNode;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.MapDifference;
import com.google.common.collect.MapDifference.ValueDifference;
import com.google.common.collect.Maps;
@@ -50,12 +47,10 @@
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
@@ -78,7 +73,7 @@
* .generateDifferenceStatements(true, true);
*
*
- * or execute the {@link #main(String[]) main()} function with the {@link
+ * or execute the {@link #main(String[]) main()} function with the {@link
* DdlDiffOptions#buildOptions() appropriate command line options}.
*/
public class DdlDiff {
@@ -124,12 +119,11 @@ private DdlDiff(DatbaseDefinition originalDb, DatbaseDefinition newDb, String da
}
}
+ /** Generate statements to convert the original to the new DB DDL. */
public List generateDifferenceStatements(Map options)
throws DdlDiffException {
ImmutableList.Builder output = ImmutableList.builder();
- boolean allowDropStatements = options.get(ALLOW_DROP_STATEMENTS_OPT);
-
if (!indexDifferences.entriesDiffering().isEmpty()
&& !options.get(ALLOW_RECREATE_INDEXES_OPT)) {
throw new DdlDiffException(
@@ -159,7 +153,7 @@ public List generateDifferenceStatements(Map options)
}
// Drop deleted indexes.
- if (allowDropStatements) {
+ if (options.get(ALLOW_DROP_STATEMENTS_OPT)) {
// Drop deleted indexes.
for (String indexName : indexDifferences.entriesOnlyOnLeft().keySet()) {
LOG.info("Dropping deleted index: {}", indexName);
@@ -168,7 +162,7 @@ public List generateDifferenceStatements(Map options)
}
// Drop deleted change streams.
- if (allowDropStatements) {
+ if (options.get(ALLOW_DROP_STATEMENTS_OPT)) {
// Drop deleted indexes.
for (String changeStreamName : changeStreamDifferences.entriesOnlyOnLeft().keySet()) {
LOG.info("Dropping deleted change stream: {}", changeStreamName);
@@ -205,7 +199,7 @@ public List generateDifferenceStatements(Map options)
output.add("ALTER TABLE " + tableName + " DROP ROW DELETION POLICY");
}
- if (allowDropStatements) {
+ if (options.get(ALLOW_DROP_STATEMENTS_OPT)) {
// Drop tables that have been deleted -- need to do it in reverse creation order.
List reverseOrderedTableNames =
new ArrayList<>(originalDb.tablesInCreationOrder().keySet());
@@ -538,16 +532,16 @@ private static String generateOptionsUpdates(MapDifference optio
}
}
- static DdlDiff build(String originalDDL, String newDDL) throws DdlDiffException {
+ static DdlDiff build(String originalDdl, String newDdl) throws DdlDiffException {
List originalStatements;
List newStatements;
try {
- originalStatements = parseDDL(Strings.nullToEmpty(originalDDL));
+ originalStatements = parseDdl(Strings.nullToEmpty(originalDdl));
} catch (DdlDiffException e) {
throw new DdlDiffException("Failed parsing ORIGINAL DDL: " + e.getMessage(), e);
}
try {
- newStatements = parseDDL(Strings.nullToEmpty(newDDL));
+ newStatements = parseDdl(Strings.nullToEmpty(newDdl));
} catch (DdlDiffException e) {
throw new DdlDiffException("Failed parsing NEW DDL: " + e.getMessage(), e);
}
@@ -596,7 +590,7 @@ private static String getDatabaseNameFromAlterDatabase(List st
}
@VisibleForTesting
- static List parseDDL(String original) throws DdlDiffException {
+ static List parseDdl(String original) throws DdlDiffException {
// Remove "--" comments and split by ";"
List statements = Splitter.on(';').splitToList(original.replaceAll("--.*(\n|$)", ""));
ArrayList ddlStatements = new ArrayList<>(statements.size());
@@ -678,6 +672,11 @@ static List parseDDL(String original) throws DdlDiffException
return ddlStatements;
}
+ /**
+ * Main entrypoint for this tool.
+ *
+ * @see DdlDiffOptions.java for command line options.
+ */
public static void main(String[] args) {
DdlDiffOptions options = DdlDiffOptions.parseCommandLine(args);
@@ -707,142 +706,3 @@ public static void main(String[] args) {
}
}
}
-
-/**
- * Wrapper class for Check and Foreign Key constraints to include the table name for when they are
- * separated from their create table/alter table statements in
- * separateTablesIndexesConstraintsTtls().
- */
-@AutoValue
-abstract class ConstraintWrapper {
-
- static ConstraintWrapper create(String tableName, SimpleNode constraint) {
- if (!(constraint instanceof ASTforeign_key) && !(constraint instanceof ASTcheck_constraint)) {
- throw new IllegalArgumentException("not a valid constraint type : " + constraint.toString());
- }
- return new AutoValue_ConstraintWrapper(tableName, constraint);
- }
-
- abstract String tableName();
-
- abstract SimpleNode constraint();
-
- String getName() {
- if (constraint() instanceof ASTcheck_constraint) {
- return ((ASTcheck_constraint) constraint()).getName();
- }
- if (constraint() instanceof ASTforeign_key) {
- return ((ASTforeign_key) constraint()).getName();
- }
- throw new IllegalArgumentException("not a valid constraint type : " + constraint().toString());
- }
-}
-
-/**
- * Separarates the different DDL creation statements into separate maps.
- *
- * Constraints which were created inline with their table are separated into a map with any other
- * ALTER statements which adds constraints.
- *
- *
This allows the diff tool to handle these objects which are created inline with the table in
- * the same way as if they were created separately with ALTER statements.
- */
-@AutoValue
-abstract class DatbaseDefinition {
- static DatbaseDefinition create(List statements) {
- // Use LinkedHashMap to preserve creation order in original DDL.
- LinkedHashMap tablesInCreationOrder = new LinkedHashMap<>();
- LinkedHashMap indexes = new LinkedHashMap<>();
- LinkedHashMap constraints = new LinkedHashMap<>();
- LinkedHashMap ttls = new LinkedHashMap<>();
- LinkedHashMap changeStreams = new LinkedHashMap<>();
- LinkedHashMap alterDatabaseOptions = new LinkedHashMap<>();
-
- for (ASTddl_statement ddlStatement : statements) {
- final SimpleNode statement = (SimpleNode) ddlStatement.jjtGetChild(0);
-
- switch (statement.getId()) {
- case DdlParserTreeConstants.JJTCREATE_TABLE_STATEMENT:
- {
- ASTcreate_table_statement createTable = (ASTcreate_table_statement) statement;
- // Remove embedded constraint statements from the CreateTable node
- // as they are taken into account via `constraints`
- tablesInCreationOrder.put(createTable.getTableName(), createTable.clearConstraints());
-
- // convert embedded constraint statements into wrapper object with table name
- // use a single map for all foreign keys, constraints and row deletion polcies whether
- // created in table or externally
- createTable.getConstraints().values().stream()
- .map(c -> ConstraintWrapper.create(createTable.getTableName(), c))
- .forEach(c -> constraints.put(c.getName(), c));
-
- // Move embedded Row Deletion Policies
- final Optional rowDeletionPolicyClause =
- createTable.getRowDeletionPolicyClause();
- rowDeletionPolicyClause.ifPresent(rdp -> ttls.put(createTable.getTableName(), rdp));
- }
- break;
- case DdlParserTreeConstants.JJTCREATE_INDEX_STATEMENT:
- indexes.put(
- ((ASTcreate_index_statement) statement).getIndexName(),
- (ASTcreate_index_statement) statement);
- break;
- case DdlParserTreeConstants.JJTALTER_TABLE_STATEMENT:
- {
- // Alter table can be adding Index, Constraint or Row Deletion Policy
- ASTalter_table_statement alterTable = (ASTalter_table_statement) statement;
- final String tableName = alterTable.jjtGetChild(0).toString();
-
- if (alterTable.jjtGetChild(1) instanceof ASTforeign_key
- || alterTable.jjtGetChild(1) instanceof ASTcheck_constraint) {
- ConstraintWrapper constraint =
- ConstraintWrapper.create(tableName, (SimpleNode) alterTable.jjtGetChild(1));
- constraints.put(constraint.getName(), constraint);
-
- } else if (statement.jjtGetChild(1) instanceof ASTadd_row_deletion_policy) {
- ttls.put(
- tableName,
- (ASTrow_deletion_policy_clause) alterTable.jjtGetChild(1).jjtGetChild(0));
- } else {
- // other ALTER statements are not supported.
- throw new IllegalArgumentException(
- "Unsupported ALTER TABLE statement: "
- + ASTTreeUtils.tokensToString(ddlStatement));
- }
- }
- break;
- case DdlParserTreeConstants.JJTALTER_DATABASE_STATEMENT:
- alterDatabaseOptions.putAll(
- ((ASTalter_database_statement) statement).getOptionsClause().getKeyValueMap());
- break;
- case DdlParserTreeConstants.JJTCREATE_CHANGE_STREAM_STATEMENT:
- changeStreams.put(
- ((ASTcreate_change_stream_statement) statement).getName(),
- (ASTcreate_change_stream_statement) statement);
- break;
- default:
- throw new IllegalArgumentException(
- "Unsupported statement: " + ASTTreeUtils.tokensToString(ddlStatement));
- }
- }
- return new AutoValue_DatbaseDefinition(
- ImmutableMap.copyOf(tablesInCreationOrder),
- ImmutableMap.copyOf(indexes),
- ImmutableMap.copyOf(constraints),
- ImmutableMap.copyOf(ttls),
- ImmutableMap.copyOf(changeStreams),
- ImmutableMap.copyOf(alterDatabaseOptions));
- }
-
- abstract ImmutableMap tablesInCreationOrder();
-
- abstract ImmutableMap indexes();
-
- abstract ImmutableMap constraints();
-
- abstract ImmutableMap ttls();
-
- abstract ImmutableMap changeStreams();
-
- abstract ImmutableMap alterDatabaseOptions();
-}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffException.java b/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffException.java
index 1487bda..d9731de 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffException.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffException.java
@@ -16,6 +16,7 @@
package com.google.cloud.solutions.spannerddl.diff;
+/** Exception raised when failing to Diff 2 DDL files. */
public class DdlDiffException extends Exception {
public DdlDiffException(String s) {
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffOptions.java b/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffOptions.java
index 52969b8..b6aa8a4 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffOptions.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffOptions.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.google.cloud.solutions.spannerddl.diff;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -133,6 +134,7 @@ static void printHelpAndExit(int exitStatus) {
System.exit(exitStatus);
}
+ /** Parse the command line according to defined options. */
public static DdlDiffOptions parseCommandLine(String[] args) {
try {
CommandLine commandLine = new DefaultParser().parse(buildOptions(), args);
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_database_statement.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_database_statement.java
index c583efc..80d4be1 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_database_statement.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_database_statement.java
@@ -15,7 +15,7 @@
*/
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
public class ASTalter_database_statement extends SimpleNode {
public ASTalter_database_statement(int id) {
@@ -31,7 +31,7 @@ public ASToptions_clause getOptionsClause() {
}
public String getDbName() {
- return ASTTreeUtils.tokensToString((ASTdb_name) jjtGetChild(0));
+ return AstTreeUtils.tokensToString((ASTdb_name) jjtGetChild(0));
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_table_statement.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_table_statement.java
index aafa3b1..4f9c14d 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_table_statement.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTalter_table_statement.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/** Abstract Syntax Tree parser object for "alter_table_statement" token */
public class ASTalter_table_statement extends SimpleNode {
@@ -55,7 +55,7 @@ public String toString() {
ret.append(alterTableAction.jjtGetChild(0));
} else {
throw new IllegalArgumentException(
- "Unrecognised Alter Table action in: " + ASTTreeUtils.tokensToString(this));
+ "Unrecognised Alter Table action in: " + AstTreeUtils.tokensToString(this));
}
return ret.toString();
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTchange_stream_for_clause.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTchange_stream_for_clause.java
index 55128cf..c993950 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTchange_stream_for_clause.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTchange_stream_for_clause.java
@@ -15,7 +15,7 @@
*/
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
public class ASTchange_stream_for_clause extends SimpleNode {
public ASTchange_stream_for_clause(int id) {
@@ -29,9 +29,9 @@ public ASTchange_stream_for_clause(DdlParser p, int id) {
@Override
public String toString() {
ASTchange_stream_tracked_tables tables =
- ASTTreeUtils.getOptionalChildByType(children, ASTchange_stream_tracked_tables.class);
+ AstTreeUtils.getOptionalChildByType(children, ASTchange_stream_tracked_tables.class);
if (tables != null) {
- return "FOR " + ASTTreeUtils.tokensToString(tables, false);
+ return "FOR " + AstTreeUtils.tokensToString(tables, false);
}
return "FOR ALL";
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcheck_constraint.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcheck_constraint.java
index 7897f05..2fdc5fb 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcheck_constraint.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcheck_constraint.java
@@ -15,7 +15,7 @@
*/
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
public class ASTcheck_constraint extends SimpleNode {
@@ -30,7 +30,7 @@ public ASTcheck_constraint(DdlParser p, int id) {
public String getName() {
// name is optional
if (children[0] instanceof ASTconstraint_name) {
- return ASTTreeUtils.tokensToString((ASTconstraint_name) children[0]);
+ return AstTreeUtils.tokensToString((ASTconstraint_name) children[0]);
} else {
return ASTcreate_table_statement.ANONYMOUS_NAME;
}
@@ -41,7 +41,7 @@ public String getExpression() {
if (children[0] instanceof ASTconstraint_name) {
child++;
}
- return ASTTreeUtils.tokensToString((ASTcheck_constraint_expression) children[child], false);
+ return AstTreeUtils.tokensToString((ASTcheck_constraint_expression) children[child], false);
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_def.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_def.java
index 27f1fdf..193f8ba 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_def.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_def.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
import javax.annotation.Nullable;
@@ -43,23 +43,23 @@ public ASTcolumn_type getColumnType() {
}
public ASTgeneration_clause getGenerationClause() {
- return ASTTreeUtils.getOptionalChildByType(children, ASTgeneration_clause.class);
+ return AstTreeUtils.getOptionalChildByType(children, ASTgeneration_clause.class);
}
public ASTcolumn_default_clause getColumnDefaultClause() {
- return ASTTreeUtils.getOptionalChildByType(children, ASTcolumn_default_clause.class);
+ return AstTreeUtils.getOptionalChildByType(children, ASTcolumn_default_clause.class);
}
public boolean isNotNull() {
- return ASTTreeUtils.getOptionalChildByType(children, ASTnot_null.class) != null;
+ return AstTreeUtils.getOptionalChildByType(children, ASTnot_null.class) != null;
}
public @Nullable ASToptions_clause getOptionsClause() {
- return ASTTreeUtils.getOptionalChildByType(children, ASToptions_clause.class);
+ return AstTreeUtils.getOptionalChildByType(children, ASToptions_clause.class);
}
public boolean isHidden() {
- return ASTTreeUtils.getOptionalChildByType(children, ASThidden.class) != null;
+ return AstTreeUtils.getOptionalChildByType(children, ASThidden.class) != null;
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_default_clause.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_default_clause.java
index 52a9316..3baec07 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_default_clause.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_default_clause.java
@@ -15,7 +15,7 @@
*/
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
public class ASTcolumn_default_clause extends SimpleNode {
public ASTcolumn_default_clause(int id) {
@@ -34,7 +34,7 @@ public boolean equals(Object other) {
@Override
public String toString() {
return "DEFAULT ("
- + ASTTreeUtils.tokensToString((ASTcolumn_default_expression) jjtGetChild(0))
+ + AstTreeUtils.tokensToString((ASTcolumn_default_expression) jjtGetChild(0))
+ ")";
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_length.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_length.java
index 8faa905..9570b6c 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_length.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_length.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/** Abstract Syntax Tree parser object for "column_length" token */
public class ASTcolumn_length extends SimpleNode {
@@ -31,7 +31,7 @@ public ASTcolumn_length(DdlParser p, int id) {
@Override
public String toString() {
- return ASTTreeUtils.tokensToString(this);
+ return AstTreeUtils.tokensToString(this);
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_type.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_type.java
index 8002286..71eb909 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_type.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumn_type.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import java.util.Locale;
/** Abstract Syntax Tree parser object for "column_type" token */
@@ -62,10 +62,10 @@ public String toString() {
case "ARRAY":
return "ARRAY<" + ((ASTcolumn_type) children[0]) + ">";
case "PG": // PG.pgtype
- return ASTTreeUtils.tokensToString(this).toUpperCase(Locale.ROOT);
+ return AstTreeUtils.tokensToString(this).toUpperCase(Locale.ROOT);
case "STRUCT":
if (jjtGetNumChildren() > 0) {
- return ASTTreeUtils.tokensToString(this);
+ return AstTreeUtils.tokensToString(this);
} else {
return "STRUCT <>";
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumns.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumns.java
index 322cdff..216bed4 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumns.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcolumns.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
public class ASTcolumns extends SimpleNode {
@@ -34,7 +34,7 @@ public String toString() {
return "( "
+ Joiner.on(", ")
.skipNulls()
- .join(ASTTreeUtils.getChildrenAssertType(children, ASTkey_part.class))
+ .join(AstTreeUtils.getChildrenAssertType(children, ASTkey_part.class))
+ " )";
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_change_stream_statement.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_change_stream_statement.java
index 66ccafa..2cfba13 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_change_stream_statement.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_change_stream_statement.java
@@ -15,7 +15,7 @@
*/
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
public class ASTcreate_change_stream_statement extends SimpleNode {
@@ -28,15 +28,15 @@ public ASTcreate_change_stream_statement(DdlParser p, int id) {
}
public String getName() {
- return ASTTreeUtils.getChildByType(children, ASTname.class).toString();
+ return AstTreeUtils.getChildByType(children, ASTname.class).toString();
}
public ASTchange_stream_for_clause getForClause() {
- return ASTTreeUtils.getOptionalChildByType(children, ASTchange_stream_for_clause.class);
+ return AstTreeUtils.getOptionalChildByType(children, ASTchange_stream_for_clause.class);
}
public ASToptions_clause getOptionsClause() {
- return ASTTreeUtils.getOptionalChildByType(children, ASToptions_clause.class);
+ return AstTreeUtils.getOptionalChildByType(children, ASToptions_clause.class);
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_index_statement.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_index_statement.java
index 201ba0a..d8dcf3f 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_index_statement.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_index_statement.java
@@ -16,10 +16,10 @@
package com.google.cloud.solutions.spannerddl.parser;
-import static com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils.getChildByType;
-import static com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils.getOptionalChildByType;
+import static com.google.cloud.solutions.spannerddl.diff.AstTreeUtils.getChildByType;
+import static com.google.cloud.solutions.spannerddl.diff.AstTreeUtils.getOptionalChildByType;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
public class ASTcreate_index_statement extends SimpleNode
@@ -34,7 +34,7 @@ public ASTcreate_index_statement(DdlParser p, int id) {
}
public String getIndexName() {
- return ASTTreeUtils.getChildByType(children, ASTname.class).toString();
+ return AstTreeUtils.getChildByType(children, ASTname.class).toString();
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_table_statement.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_table_statement.java
index a8c0747..69c3d42 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_table_statement.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTcreate_table_statement.java
@@ -16,9 +16,9 @@
package com.google.cloud.solutions.spannerddl.parser;
-import static com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils.getOptionalChildByType;
+import static com.google.cloud.solutions.spannerddl.diff.AstTreeUtils.getOptionalChildByType;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -43,7 +43,7 @@ public ASTcreate_table_statement(DdlParser p, int id) {
}
public String getTableName() {
- return ASTTreeUtils.tokensToString(ASTTreeUtils.getChildByType(children, ASTname.class));
+ return AstTreeUtils.tokensToString(AstTreeUtils.getChildByType(children, ASTname.class));
}
public Map getColumns() {
@@ -73,7 +73,7 @@ public Map getConstraints() {
}
public synchronized ASTprimary_key getPrimaryKey() {
- return ASTTreeUtils.getChildByType(children, ASTprimary_key.class);
+ return AstTreeUtils.getChildByType(children, ASTprimary_key.class);
}
public synchronized Optional getInterleaveClause() {
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTexpression.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTexpression.java
index 0226cea..eb0ab55 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTexpression.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTexpression.java
@@ -15,7 +15,7 @@
*/
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
public class ASTexpression extends SimpleNode {
@@ -29,7 +29,7 @@ public ASTexpression(DdlParser p, int id) {
@Override
public String toString() {
- return ASTTreeUtils.tokensToString(this, false);
+ return AstTreeUtils.tokensToString(this, false);
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTforeign_key.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTforeign_key.java
index c75e022..ba1b5ce 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTforeign_key.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTforeign_key.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
import java.util.Arrays;
import java.util.List;
@@ -35,7 +35,7 @@ public ASTforeign_key(DdlParser p, int id) {
public String getName() {
// name is optional
if (children[0] instanceof ASTconstraint_name) {
- return ASTTreeUtils.tokensToString((ASTconstraint_name) children[0]);
+ return AstTreeUtils.tokensToString((ASTconstraint_name) children[0]);
} else {
return ASTcreate_table_statement.ANONYMOUS_NAME;
}
@@ -48,7 +48,7 @@ public List getConstrainedColumnNames() {
private List identifierListToStringList(ASTidentifier_list idList) {
return Arrays.stream(idList.children)
- .map(o -> ASTTreeUtils.tokensToString((ASTidentifier) o, false))
+ .map(o -> AstTreeUtils.tokensToString((ASTidentifier) o, false))
.collect(Collectors.toList());
}
@@ -58,7 +58,7 @@ public String getReferencedTableName() {
// skip constraint name when specified.
child++;
}
- return ASTTreeUtils.tokensToString((ASTreferenced_table) children[child], false);
+ return AstTreeUtils.tokensToString((ASTreferenced_table) children[child], false);
}
public List getReferencedColumnNames() {
@@ -71,7 +71,7 @@ public List getReferencedColumnNames() {
}
public String getDeleteOption() {
- ASTon_delete deleteOption = ASTTreeUtils.getOptionalChildByType(children, ASTon_delete.class);
+ ASTon_delete deleteOption = AstTreeUtils.getOptionalChildByType(children, ASTon_delete.class);
if (deleteOption != null) {
return " " + deleteOption;
} else {
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTindex_interleave_clause.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTindex_interleave_clause.java
index 74b3a3b..9b0cf76 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTindex_interleave_clause.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTindex_interleave_clause.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/** Abstract Syntax Tree parser object for "index_interleave_clause" token */
public class ASTindex_interleave_clause extends SimpleNode {
@@ -31,6 +31,6 @@ public ASTindex_interleave_clause(DdlParser p, int id) {
@Override
public String toString() {
- return "INTERLEAVE IN " + ASTTreeUtils.tokensToString((ASTinterleave_in) children[0]);
+ return "INTERLEAVE IN " + AstTreeUtils.tokensToString((ASTinterleave_in) children[0]);
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTkey.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTkey.java
index b2698b9..2ddca2c 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTkey.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTkey.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
public class ASTkey extends SimpleNode {
@@ -35,7 +35,7 @@ public String toString() {
return jjtGetFirstToken().toString();
}
return "("
- + Joiner.on(", ").join(ASTTreeUtils.getChildrenAssertType(children, ASTkey_part.class))
+ + Joiner.on(", ").join(AstTreeUtils.getChildrenAssertType(children, ASTkey_part.class))
+ ")";
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTname.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTname.java
index 0274fe5..25f7bc8 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTname.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTname.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/** Abstract Syntax Tree parser object for "name" token */
public class ASTname extends SimpleNode {
@@ -31,6 +31,6 @@ public ASTname(DdlParser p, int id) {
@Override
public String toString() {
- return ASTTreeUtils.tokensToString(this, false);
+ return AstTreeUtils.tokensToString(this, false);
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASToption_key_val.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASToption_key_val.java
index eb16eed..8c53b8b 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASToption_key_val.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASToption_key_val.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/** Abstract Syntax Tree parser object for "option_key_val" token */
public class ASToption_key_val extends SimpleNode {
@@ -39,6 +39,6 @@ public String getKey() {
}
public String getValue() {
- return ASTTreeUtils.tokensToString((SimpleNode) children[1]);
+ return AstTreeUtils.tokensToString((SimpleNode) children[1]);
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASToptions_clause.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASToptions_clause.java
index 8086490..47cd75c 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASToptions_clause.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASToptions_clause.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
import java.util.Map;
import java.util.stream.Collectors;
@@ -34,12 +34,12 @@ public ASToptions_clause(DdlParser p, int id) {
@Override
public String toString() {
return "OPTIONS ("
- + Joiner.on(",").join(ASTTreeUtils.getChildrenAssertType(children, ASToption_key_val.class))
+ + Joiner.on(",").join(AstTreeUtils.getChildrenAssertType(children, ASToption_key_val.class))
+ ")";
}
public Map getKeyValueMap() {
- return ASTTreeUtils.getChildrenAssertType(children, ASToption_key_val.class).stream()
+ return AstTreeUtils.getChildrenAssertType(children, ASToption_key_val.class).stream()
.collect(Collectors.toMap(ASToption_key_val::getKey, ASToption_key_val::getValue));
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTpath.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTpath.java
index cb6866f..67e5bf2 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTpath.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTpath.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/** Abstract Syntax Tree parser object for "path" token */
public class ASTpath extends SimpleNode {
@@ -31,6 +31,6 @@ public ASTpath(DdlParser p, int id) {
@Override
public String toString() {
- return ASTTreeUtils.tokensToString(this, false);
+ return AstTreeUtils.tokensToString(this, false);
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTprimary_key.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTprimary_key.java
index d893122..9f70d8c 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTprimary_key.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTprimary_key.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
/** Abstract Syntax Tree parser object for "primary_Key" token */
@@ -33,7 +33,7 @@ public ASTprimary_key(DdlParser p, int id) {
@Override
public String toString() {
return "PRIMARY KEY ("
- + Joiner.on(", ").join(ASTTreeUtils.getChildrenAssertType(children, ASTkey_part.class))
+ + Joiner.on(", ").join(AstTreeUtils.getChildrenAssertType(children, ASTkey_part.class))
+ ")";
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTreferential_action.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTreferential_action.java
index 4d1730d..78725a7 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTreferential_action.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTreferential_action.java
@@ -15,7 +15,7 @@
*/
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
public class ASTreferential_action extends SimpleNode {
public ASTreferential_action(int id) {
@@ -28,7 +28,7 @@ public ASTreferential_action(DdlParser p, int id) {
@Override
public String toString() {
- return ASTTreeUtils.tokensToString(this);
+ return AstTreeUtils.tokensToString(this);
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTrow_deletion_policy_clause.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTrow_deletion_policy_clause.java
index a0b5446..b4cf3ea 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTrow_deletion_policy_clause.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTrow_deletion_policy_clause.java
@@ -15,7 +15,7 @@
*/
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/**
* This defines the row deletion policy used in: Create Table, Alter Table add ROW DELETION POLICY
@@ -33,8 +33,8 @@ public ASTrow_deletion_policy_clause(DdlParser p, int id) {
@Override
public String toString() {
ASTrow_deletion_policy_expression expression =
- ASTTreeUtils.getChildByType(children, ASTrow_deletion_policy_expression.class);
- return "ROW DELETION POLICY (" + ASTTreeUtils.tokensToString(expression) + ")";
+ AstTreeUtils.getChildByType(children, ASTrow_deletion_policy_expression.class);
+ return "ROW DELETION POLICY (" + AstTreeUtils.tokensToString(expression) + ")";
}
@Override
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTstored_column_list.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTstored_column_list.java
index 661cfb4..b139ffd 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTstored_column_list.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTstored_column_list.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
public class ASTstored_column_list extends SimpleNode {
@@ -32,7 +32,7 @@ public ASTstored_column_list(DdlParser p, int id) {
@Override
public String toString() {
return "STORING ( "
- + Joiner.on(", ").join(ASTTreeUtils.getChildrenAssertType(children, ASTstored_column.class))
+ + Joiner.on(", ").join(AstTreeUtils.getChildrenAssertType(children, ASTstored_column.class))
+ " )";
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable.java
index e91365c..d215cec 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/** Abstract Syntax Tree parser object for "table" token */
public class ASTtable extends SimpleNode {
@@ -31,6 +31,6 @@ public ASTtable(DdlParser p, int id) {
@Override
public String toString() {
- return ASTTreeUtils.tokensToString(this);
+ return AstTreeUtils.tokensToString(this);
}
}
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable_interleave_clause.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable_interleave_clause.java
index df09a08..4965756 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable_interleave_clause.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable_interleave_clause.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
import com.google.common.base.Joiner;
/** Abstract Syntax Tree parser object for "table_interleave_clause" token */
@@ -30,7 +30,7 @@ public ASTtable_interleave_clause(DdlParser p, int id) {
}
public String getParentTableName() {
- return ASTTreeUtils.tokensToString((ASTinterleave_in) children[0]);
+ return AstTreeUtils.tokensToString((ASTinterleave_in) children[0]);
}
public String getOnDelete() {
diff --git a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable_name.java b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable_name.java
index 9e6f517..34e8d17 100644
--- a/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable_name.java
+++ b/src/main/java/com/google/cloud/solutions/spannerddl/parser/ASTtable_name.java
@@ -16,7 +16,7 @@
package com.google.cloud.solutions.spannerddl.parser;
-import com.google.cloud.solutions.spannerddl.diff.ASTTreeUtils;
+import com.google.cloud.solutions.spannerddl.diff.AstTreeUtils;
/** Abstract Syntax Tree parser object for "table_name" token */
public class ASTtable_name extends SimpleNode {
@@ -31,6 +31,6 @@ public ASTtable_name(DdlParser p, int id) {
@Override
public String toString() {
- return ASTTreeUtils.tokensToString(this);
+ return AstTreeUtils.tokensToString(this);
}
}
diff --git a/src/test/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffTest.java b/src/test/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffTest.java
index cd1bb3c..ef98b8d 100644
--- a/src/test/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffTest.java
+++ b/src/test/java/com/google/cloud/solutions/spannerddl/diff/DdlDiffTest.java
@@ -45,7 +45,7 @@ public void parseMultiDdlStatements() throws DdlDiffException {
+ "-- more comment\n"
+ "; -- stray semicolon";
- List result = DdlDiff.parseDDL(DDL);
+ List result = DdlDiff.parseDdl(DDL);
assertThat(result).hasSize(4);
@@ -63,7 +63,7 @@ public void parseMultiDdlStatements() throws DdlDiffException {
@Test
public void parseCreateTable_anonForeignKey() throws DdlDiffException {
try {
- DdlDiff.parseDDL(
+ DdlDiff.parseDdl(
"create table test ("
+ "intcol int64 not null, "
+ "FOREIGN KEY(col1, col2) REFERENCES other_table(other_col1, other_col2)"
@@ -79,7 +79,7 @@ public void parseCreateTable_anonForeignKey() throws DdlDiffException {
@Test
public void parseCreateTable_anonCheckConstraint() throws DdlDiffException {
try {
- DdlDiff.parseDDL(
+ DdlDiff.parseDdl(
"create table test ("
+ "intcol int64 not null, "
+ "check (intcol>1)"
@@ -94,37 +94,37 @@ public void parseCreateTable_anonCheckConstraint() throws DdlDiffException {
@Test(expected = IllegalArgumentException.class)
public void parseDDLNoAlterTableAlterColumn() throws DdlDiffException {
- DdlDiff.parseDDL("alter table test1 alter column col1 int64 not null");
+ DdlDiff.parseDdl("alter table test1 alter column col1 int64 not null");
}
@Test(expected = IllegalArgumentException.class)
public void parseDDLNoAlterTableAddColumn() throws DdlDiffException {
- DdlDiff.parseDDL("alter table test1 add column col1 int64 not null");
+ DdlDiff.parseDdl("alter table test1 add column col1 int64 not null");
}
@Test(expected = IllegalArgumentException.class)
public void parseDDLNoAlterTableDropColumn() throws DdlDiffException {
- DdlDiff.parseDDL("alter table test1 drop column col1");
+ DdlDiff.parseDdl("alter table test1 drop column col1");
}
@Test(expected = IllegalArgumentException.class)
public void parseDDLNoAlterTableDropConstraint() throws DdlDiffException {
- DdlDiff.parseDDL("alter table test1 drop constraint xxx");
+ DdlDiff.parseDdl("alter table test1 drop constraint xxx");
}
@Test(expected = IllegalArgumentException.class)
public void parseDDLNoAlterTableSetOnDelete() throws DdlDiffException {
- DdlDiff.parseDDL("alter table test1 set on delete cascade");
+ DdlDiff.parseDdl("alter table test1 set on delete cascade");
}
@Test
public void parseDDLAlterTableAddConstraint() throws DdlDiffException {
- DdlDiff.parseDDL("alter table test1 add constraint XXX FOREIGN KEY (yyy) references zzz(xxx)");
+ DdlDiff.parseDdl("alter table test1 add constraint XXX FOREIGN KEY (yyy) references zzz(xxx)");
}
@Test(expected = IllegalArgumentException.class)
public void parseDDLNoAlterTableAddAnonConstraint() throws DdlDiffException {
- DdlDiff.parseDDL("alter table test1 add FOREIGN KEY (yyy) references zzz(xxx)");
+ DdlDiff.parseDdl("alter table test1 add FOREIGN KEY (yyy) references zzz(xxx)");
}
@Test