Repository navigation
Expand file tree
/
Copy pathCreateTable.java
More file actions
784 lines (674 loc) · 25.9 KB
/
Copy pathCreateTable.java
File metadata and controls
784 lines (674 loc) · 25.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2019 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.sf.jsqlparser.expression.SpannerInterleaveIn;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.LikeClause;
import net.sf.jsqlparser.statement.StatementVisitor;
import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.Select;
public class CreateTable extends ASTNodeAccessImpl implements Statement {
private boolean tableOptionsAfterPartition;
private net.sf.jsqlparser.statement.execute.Execute execute;
private Table table;
private boolean unlogged = false;
private List<String> createOptionsStrings;
private List<String> tableOptionsStrings;
private List<TableOption> tableOptions;
private List<ColumnDefinition> columnDefinitions;
private List<String> columns;
private List<Index> indexes;
private List<NamedConstraint> tableConstraints;
private List<TableElement> tableElements;
private Select select;
private DuplicateHandling duplicateHandling;
private Table likeTable;
private Table cloneTable;
private List<Table> inherits;
private ColDataType ofType;
private boolean selectParenthesis;
private boolean useAsKeyword = true;
private Boolean withData;
private boolean ifNotExists = false;
private boolean orReplace = false;
private TablePartitioning partitioning;
private Table partitionOf;
private PartitionBound partitionBound;
private RowMovement rowMovement;
private SpannerInterleaveIn interleaveIn = null;
public enum DuplicateHandling {
IGNORE, REPLACE
}
public boolean isTableOptionsAfterPartition() {
return tableOptionsAfterPartition;
}
public void setTableOptionsAfterPartition(boolean tableOptionsAfterPartition) {
this.tableOptionsAfterPartition = tableOptionsAfterPartition;
}
/** Prepared statement source of PostgreSQL CREATE TABLE AS EXECUTE. */
public net.sf.jsqlparser.statement.execute.Execute getExecute() {
return execute;
}
public void setExecute(net.sf.jsqlparser.statement.execute.Execute execute) {
this.execute = execute;
select = null;
selectParenthesis = false;
}
/** The structured SERVER clause, also present in the shared table-options list. */
public ForeignTableOptions getForeignTableOptions() {
if (tableOptions != null) {
for (TableOption option : tableOptions) {
if (option.getForeignTableOptions() != null) {
return option.getForeignTableOptions();
}
}
}
return null;
}
/** MySQL's duplicate-key handling when creating a table from a query; null if omitted. */
public DuplicateHandling getDuplicateHandling() {
return duplicateHandling;
}
public void setDuplicateHandling(DuplicateHandling duplicateHandling) {
this.duplicateHandling = duplicateHandling;
}
@Override
public <T, S> T accept(StatementVisitor<T> statementVisitor, S context) {
return statementVisitor.visit(this, context);
}
public Table getTable() {
return table;
}
public void setTable(Table table) {
this.table = table;
}
public boolean isUnlogged() {
return unlogged;
}
public void setUnlogged(boolean unlogged) {
this.unlogged = unlogged;
}
/**
* @return a list of {@link ColumnDefinition}s of this table. When ordered table elements are
* present, this is a mutable view of the column definitions in that list.
*/
public List<ColumnDefinition> getColumnDefinitions() {
return columnDefinitions;
}
public void setColumnDefinitions(List<ColumnDefinition> list) {
if (tableElements == null) {
columnDefinitions = list;
} else {
TableElementList.replace(tableElements, ColumnDefinition.class, list);
}
}
public List<String> getColumns() {
return this.columns;
}
public void setColumns(List<String> columns) {
this.columns = columns;
}
/**
* @return a list of options (as simple strings) of this table definition, as ("TYPE", "=",
* "MYISAM"). For typed options, this is a snapshot of their current tokens; use
* {@link #getTableOptions()} to edit the structured options or
* {@link #setTableOptionsStrings(List)} to replace them with raw options.
*/
public List<String> getTableOptionsStrings() {
if (tableOptions == null) {
return tableOptionsStrings;
}
List<String> tokens = new ArrayList<>();
for (TableOption option : tableOptions) {
tokens.addAll(option.getTokens());
}
return tokens;
}
public void setTableOptionsStrings(List<String> tableOptionsStrings) {
this.tableOptionsStrings = tableOptionsStrings;
tableOptions = null;
}
/** Returns typed table options in source order. */
public List<TableOption> getTableOptions() {
return tableOptions;
}
public void setTableOptions(List<TableOption> tableOptions) {
this.tableOptions = tableOptions;
tableOptionsStrings = null;
}
/** Returns the first option of the requested kind, if present. */
public Optional<TableOption> getTableOption(TableOption.Kind kind) {
return Optional.ofNullable(tableOptions).orElseGet(Collections::emptyList).stream()
.filter(option -> option.getKind() == kind)
.findFirst();
}
public List<String> getCreateOptionsStrings() {
return createOptionsStrings;
}
public void setCreateOptionsStrings(List<String> createOptionsStrings) {
this.createOptionsStrings = createOptionsStrings;
}
/**
* Returns index declarations only. Table constraints are available through
* {@link #getTableConstraints()}. When ordered table elements are present, this is a mutable
* view of their indexes.
*/
public List<Index> getIndexes() {
return indexes;
}
/**
* Returns column and table constraint declarations in source order, including MySQL UNIQUE
* KEY/INDEX declarations, REFERENCES and explicit NOT NULL options. Ordinary DEFAULT column
* options are not classified as constraints; explicit {@link DefaultConstraint} nodes are.
* Index declarations, raw options, and constraints inherited from LIKE, a type or another table
* are not inferred.
*
* The list is an unmodifiable membership snapshot. Each view reads its original editable AST
* nodes; call this method again after inserting or removing declarations or changing a
* nullability option between NULL and NOT NULL. Typed constraint nodes remain included even
* when their kind is OTHER. For legacy construction without ordered table elements, columns
* precede table constraints.
*/
public List<ConstraintDeclaration> getConstraints() {
List<ConstraintDeclaration> declarations = new ArrayList<>();
if (tableElements != null) {
tableElements.forEach(element -> addConstraints(element, declarations));
} else {
if (columnDefinitions != null) {
columnDefinitions.forEach(column -> addConstraints(column, declarations));
}
if (tableConstraints != null) {
tableConstraints.forEach(constraint -> addConstraints(constraint, declarations));
}
}
return Collections.unmodifiableList(declarations);
}
private static void addConstraints(TableElement element,
List<ConstraintDeclaration> declarations) {
if (element instanceof ColumnDefinition) {
ColumnDefinition column = (ColumnDefinition) element;
if (column.getColumnOptions() != null) {
for (ColumnOption option : column.getColumnOptions()) {
if (option.getKind() == ColumnOption.Kind.CONSTRAINT
&& option.getConstraint() != null
|| option.getConstraintKind() != ConstraintKind.OTHER) {
declarations.add(new ConstraintDeclaration(column, option));
}
}
}
} else if (element instanceof NamedConstraint) {
declarations.add(new ConstraintDeclaration((NamedConstraint) element));
}
}
public void setIndexes(List<Index> list) {
if (tableElements == null) {
indexes = list;
} else {
TableElementList.replace(tableElements, Index.class, list);
}
}
/**
* Returns table-level constraint definitions, excluding constraints declared within columns.
* When ordered table elements are present, this is a mutable view of their constraints. Use
* {@link #getConstraints()} to inspect both column and table declarations.
*/
public List<NamedConstraint> getTableConstraints() {
return tableConstraints;
}
public void setTableConstraints(List<NamedConstraint> constraints) {
if (tableElements == null) {
tableConstraints = constraints;
} else {
TableElementList.replace(tableElements, NamedConstraint.class, constraints);
}
}
/**
* Returns columns, constraints, and indexes in the order in which they were declared.
*/
public List<TableElement> getTableElements() {
return tableElements;
}
public void setTableElements(List<TableElement> tableElements) {
this.tableElements = tableElements;
if (tableElements == null) {
columnDefinitions = null;
indexes = null;
tableConstraints = null;
return;
}
columnDefinitions = new TableElementList<>(tableElements, ColumnDefinition.class);
indexes = new TableElementList<>(tableElements, Index.class);
tableConstraints = new TableElementList<>(tableElements, NamedConstraint.class);
}
/** Returns table elements of a requested AST type while preserving their declaration order. */
public <E extends TableElement> List<E> getTableElements(Class<E> type) {
if (tableElements == null) {
return Collections.emptyList();
}
List<E> result = new ArrayList<>();
for (TableElement element : tableElements) {
if (type.isInstance(element)) {
result.add(type.cast(element));
}
}
return result;
}
public Select getSelect() {
return select;
}
public boolean isUseAsKeyword() {
return useAsKeyword;
}
public void setUseAsKeyword(boolean useAsKeyword) {
this.useAsKeyword = useAsKeyword;
}
/** Returns null for omission, true for WITH DATA, and false for WITH NO DATA. */
public Boolean getWithData() {
return withData;
}
public void setWithData(Boolean withData) {
this.withData = withData;
}
public StringBuilder appendSelectTo(StringBuilder builder,
java.util.function.Consumer<Select> selectRenderer) {
return appendQueryTo(builder, selectRenderer, builder::append);
}
public StringBuilder appendQueryTo(StringBuilder builder,
java.util.function.Consumer<Select> selectRenderer,
java.util.function.Consumer<net.sf.jsqlparser.statement.execute.Execute> executeRenderer) {
if (select != null || execute != null) {
if (duplicateHandling != null) {
builder.append(' ').append(duplicateHandling);
}
builder.append(useAsKeyword ? " AS " : " ");
if (selectParenthesis) {
builder.append("(");
}
if (execute != null) {
executeRenderer.accept(execute);
} else {
selectRenderer.accept(select);
}
if (selectParenthesis) {
builder.append(")");
}
if (withData != null) {
builder.append(withData ? " WITH DATA" : " WITH NO DATA");
}
}
return builder;
}
public void setSelect(Select select, boolean parenthesis) {
this.select = select;
this.execute = null;
this.selectParenthesis = parenthesis;
}
public Table getLikeTable() {
if (likeTable != null) {
return likeTable;
}
List<LikeClause> clauses = getTableElements(LikeClause.class);
return clauses.isEmpty() ? null : clauses.get(0).getTable();
}
/** Returns the legacy trailing LIKE source, excluding LIKE clauses inside the definition. */
public Table getTrailingLikeTable() {
return likeTable;
}
public ColDataType getOfType() {
return ofType;
}
public void setOfType(ColDataType ofType) {
this.ofType = ofType;
}
public void setLikeTable(Table likeTable, boolean parenthesis) {
List<LikeClause> clauses = getTableElements(LikeClause.class);
if (this.likeTable == null && !clauses.isEmpty()) {
if (likeTable != null) {
clauses.get(0).setTable(likeTable);
} else {
List<TableElement> elements = new ArrayList<>(tableElements);
elements.remove(clauses.get(0));
setTableElements(elements);
}
return;
}
this.likeTable = likeTable;
this.selectParenthesis = parenthesis;
}
/**
* BigQuery's {@code CREATE [SNAPSHOT] TABLE target CLONE source [FOR SYSTEM_TIME AS OF ...]}.
*/
public Table getCloneTable() {
return cloneTable;
}
public void setCloneTable(Table cloneTable) {
this.cloneTable = cloneTable;
}
public CreateTable withCloneTable(Table cloneTable) {
setCloneTable(cloneTable);
return this;
}
public boolean isIfNotExists() {
return ifNotExists;
}
public void setIfNotExists(boolean ifNotExists) {
this.ifNotExists = ifNotExists;
}
public boolean isOrReplace() {
return orReplace;
}
public void setOrReplace(boolean orReplace) {
this.orReplace = orReplace;
}
public TablePartitioning getPartitioning() {
return partitioning;
}
public void setPartitioning(TablePartitioning partitioning) {
this.partitioning = partitioning;
}
public Table getPartitionOf() {
return partitionOf;
}
public void setPartitionOf(Table partitionOf) {
this.partitionOf = partitionOf;
}
public PartitionBound getPartitionBound() {
return partitionBound;
}
public void setPartitionBound(PartitionBound partitionBound) {
this.partitionBound = partitionBound;
}
/** PostgreSQL parent tables, in declaration order; null if INHERITS is absent. */
public List<Table> getInherits() {
return inherits;
}
public void setInherits(List<Table> inherits) {
this.inherits = inherits;
}
public CreateTable withInherits(List<Table> inherits) {
setInherits(inherits);
return this;
}
/** Shared rendering of the structured parent references. */
public void appendInheritanceTo(StringBuilder builder) {
if (inherits != null) {
builder.append(" INHERITS ").append(PlainSelect.getStringList(inherits, true, true));
}
}
public boolean isSelectParenthesis() {
return selectParenthesis;
}
public void setSelectParenthesis(boolean selectParenthesis) {
this.selectParenthesis = selectParenthesis;
}
public RowMovement getRowMovement() {
return rowMovement;
}
public void setRowMovement(RowMovement rowMovement) {
this.rowMovement = rowMovement;
}
@Override
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
public String toString() {
StringBuilder b = new StringBuilder();
appendCreateClause(b);
appendColumnDefinitions(b);
appendInheritanceTo(b);
if (partitionBound != null) {
b.append(" ").append(partitionBound);
}
appendTableOptions(b);
appendTableProperties(b);
return b.toString();
}
private void appendCreateClause(StringBuilder b) {
String createOps = PlainSelect.getStringList(createOptionsStrings, false, false);
b.append("CREATE ");
if (unlogged) {
b.append("UNLOGGED ");
}
if (!"".equals(createOps)) {
b.append(createOps).append(" ");
}
if (orReplace) {
b.append("OR REPLACE ");
}
b.append("TABLE ");
if (ifNotExists) {
b.append("IF NOT EXISTS ");
}
b.append(table);
if (ofType != null) {
b.append(" OF ").append(ofType);
}
if (partitionOf != null) {
b.append(" PARTITION OF ").append(partitionOf);
}
if (cloneTable != null) {
b.append(" CLONE ").append(cloneTable);
}
}
private void appendColumnDefinitions(StringBuilder b) {
if (columns != null && !columns.isEmpty()) {
b.append(" ");
b.append(PlainSelect.getStringList(columns, true, true));
}
if (tableElements != null) {
b.append(" (");
b.append(PlainSelect.getStringList(tableElements, true, false));
b.append(")");
} else {
List<TableElement> definitions = new ArrayList<>();
if (columnDefinitions != null) {
definitions.addAll(columnDefinitions);
}
if (tableConstraints != null) {
definitions.addAll(tableConstraints);
}
if (indexes != null) {
definitions.addAll(indexes);
}
if (!definitions.isEmpty()) {
b.append(" (");
b.append(PlainSelect.getStringList(definitions, true, false));
b.append(")");
}
}
}
public void appendTableOptionsTo(StringBuilder builder,
java.util.function.Consumer<net.sf.jsqlparser.expression.Expression> expressionPrinter) {
if (tableOptions != null) {
TableOption previous = null;
for (TableOption option : tableOptions) {
// SQLite requires a comma between WITHOUT ROWID and STRICT
builder.append(isSqliteTableOption(previous) && isSqliteTableOption(option)
? ", "
: " ");
option.appendTo(builder, expressionPrinter);
previous = option;
}
} else {
String options = PlainSelect.getStringList(tableOptionsStrings, false, false);
if (options != null && !options.isEmpty()) {
builder.append(' ').append(options);
}
}
}
private static boolean isSqliteTableOption(TableOption option) {
return option != null && (option.getKind() == TableOption.Kind.WITHOUT_ROWID
|| option.getKind() == TableOption.Kind.STRICT);
}
private void appendTableOptions(StringBuilder b) {
if (partitioning != null && tableOptionsAfterPartition) {
b.append(" ").append(partitioning);
}
appendTableOptionsTo(b, b::append);
if (partitioning != null && !tableOptionsAfterPartition) {
b.append(" ").append(partitioning);
}
}
private void appendTableProperties(StringBuilder b) {
if (rowMovement != null) {
b.append(" ").append(rowMovement.getMode()).append(" ROW MOVEMENT");
}
appendSelectTo(b, b::append);
if (likeTable != null) {
b.append(" LIKE ");
if (selectParenthesis) {
b.append("(");
}
b.append(likeTable);
if (selectParenthesis) {
b.append(")");
}
}
if (interleaveIn != null) {
b.append(", ").append(interleaveIn);
}
}
public CreateTable withTable(Table table) {
this.setTable(table);
return this;
}
public CreateTable withUnlogged(boolean unlogged) {
this.setUnlogged(unlogged);
return this;
}
public CreateTable withCreateOptionsStrings(List<String> createOptionsStrings) {
this.setCreateOptionsStrings(createOptionsStrings);
return this;
}
public CreateTable withSelectParenthesis(boolean selectParenthesis) {
this.setSelectParenthesis(selectParenthesis);
return this;
}
public CreateTable withIfNotExists(boolean ifNotExists) {
this.setIfNotExists(ifNotExists);
return this;
}
public CreateTable withPartitioning(TablePartitioning partitioning) {
this.setPartitioning(partitioning);
return this;
}
public CreateTable withPartitionOf(Table partitionOf) {
setPartitionOf(partitionOf);
return this;
}
public CreateTable withPartitionBound(PartitionBound partitionBound) {
setPartitionBound(partitionBound);
return this;
}
public CreateTable withRowMovement(RowMovement rowMovement) {
this.setRowMovement(rowMovement);
return this;
}
public CreateTable withTableOptionsStrings(List<String> tableOptionsStrings) {
this.setTableOptionsStrings(tableOptionsStrings);
return this;
}
public CreateTable withTableOptions(List<TableOption> tableOptions) {
this.setTableOptions(tableOptions);
return this;
}
public CreateTable withColumnDefinitions(List<ColumnDefinition> columnDefinitions) {
this.setColumnDefinitions(columnDefinitions);
return this;
}
public CreateTable withColumns(List<String> columns) {
this.setColumns(columns);
return this;
}
public CreateTable withIndexes(List<Index> indexes) {
this.setIndexes(indexes);
return this;
}
public CreateTable withTableConstraints(List<NamedConstraint> constraints) {
setTableConstraints(constraints);
return this;
}
public CreateTable withTableElements(List<TableElement> tableElements) {
this.setTableElements(tableElements);
return this;
}
public CreateTable addCreateOptionsStrings(String... createOptionsStrings) {
List<String> collection =
Optional.ofNullable(getCreateOptionsStrings()).orElseGet(ArrayList::new);
Collections.addAll(collection, createOptionsStrings);
return this.withCreateOptionsStrings(collection);
}
public CreateTable addCreateOptionsStrings(Collection<String> createOptionsStrings) {
List<String> collection =
Optional.ofNullable(getCreateOptionsStrings()).orElseGet(ArrayList::new);
collection.addAll(createOptionsStrings);
return this.withCreateOptionsStrings(collection);
}
public CreateTable addColumnDefinitions(ColumnDefinition... columnDefinitions) {
List<ColumnDefinition> collection =
Optional.ofNullable(getColumnDefinitions()).orElseGet(ArrayList::new);
Collections.addAll(collection, columnDefinitions);
return this.withColumnDefinitions(collection);
}
public CreateTable addColumnDefinitions(
Collection<? extends ColumnDefinition> columnDefinitions) {
List<ColumnDefinition> collection =
Optional.ofNullable(getColumnDefinitions()).orElseGet(ArrayList::new);
collection.addAll(columnDefinitions);
return this.withColumnDefinitions(collection);
}
public CreateTable addColumns(String... columns) {
List<String> collection = Optional.ofNullable(getColumns()).orElseGet(ArrayList::new);
Collections.addAll(collection, columns);
return this.withColumns(collection);
}
public CreateTable addColumns(Collection<String> columns) {
List<String> collection = Optional.ofNullable(getColumns()).orElseGet(ArrayList::new);
collection.addAll(columns);
return this.withColumns(collection);
}
public CreateTable addIndexes(Index... indexes) {
List<Index> collection = Optional.ofNullable(getIndexes()).orElseGet(ArrayList::new);
Collections.addAll(collection, indexes);
return this.withIndexes(collection);
}
public CreateTable addIndexes(Collection<? extends Index> indexes) {
List<Index> collection = Optional.ofNullable(getIndexes()).orElseGet(ArrayList::new);
collection.addAll(indexes);
return this.withIndexes(collection);
}
public CreateTable addTableConstraints(NamedConstraint... constraints) {
List<NamedConstraint> collection =
Optional.ofNullable(getTableConstraints()).orElseGet(ArrayList::new);
Collections.addAll(collection, constraints);
return withTableConstraints(collection);
}
public CreateTable addTableConstraints(Collection<? extends NamedConstraint> constraints) {
List<NamedConstraint> collection =
Optional.ofNullable(getTableConstraints()).orElseGet(ArrayList::new);
collection.addAll(constraints);
return withTableConstraints(collection);
}
public SpannerInterleaveIn getSpannerInterleaveIn() {
return interleaveIn;
}
public void setSpannerInterleaveIn(SpannerInterleaveIn spannerInterleaveIn) {
this.interleaveIn = spannerInterleaveIn;
}
public CreateTable withSpannerInterleaveIn(SpannerInterleaveIn spannerInterleaveIn) {
this.interleaveIn = spannerInterleaveIn;
return this;
}
}