-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathNamedConstraint.java
More file actions
117 lines (96 loc) · 3.44 KB
/
Copy pathNamedConstraint.java
File metadata and controls
117 lines (96 loc) · 3.44 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
/*-
* #%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.Collection;
import java.util.List;
import net.sf.jsqlparser.statement.select.PlainSelect;
public class NamedConstraint extends Index {
private String indexName;
private boolean useConstraintKeyword;
/**
* Returns the optional index name declared after the constraint type. This is distinct from
* {@link #getName()}, which represents the optional constraint symbol.
*
* @return the index name, or {@code null} when it was omitted
*/
public String getIndexName() {
return indexName;
}
public void setIndexName(String indexName) {
this.indexName = indexName;
}
public boolean isUseConstraintKeyword() {
return useConstraintKeyword;
}
public void setUseConstraintKeyword(boolean useConstraintKeyword) {
this.useConstraintKeyword = useConstraintKeyword;
}
@Override
public String toString() {
String idxSpecText = PlainSelect.getStringList(getIndexSpec(), false, false);
String head = useConstraintKeyword || getName() != null
? "CONSTRAINT" + (getName() != null ? " " + getName() : "") + " "
: "";
String tail = getType()
+ (indexName != null ? " " + indexName : "")
+ (getUsing() != null ? " USING " + getUsing() : "")
+ " " + PlainSelect.getStringList(getColumnsNames(), true, true) +
(!"".equals(idxSpecText) ? " " + idxSpecText : "");
return head + tail;
}
public NamedConstraint withIndexName(String indexName) {
setIndexName(indexName);
return this;
}
public NamedConstraint withUseConstraintKeyword(boolean useConstraintKeyword) {
setUseConstraintKeyword(useConstraintKeyword);
return this;
}
@Override
public NamedConstraint withName(List<String> name) {
return (NamedConstraint) super.withName(name);
}
@Override
public NamedConstraint withName(String name) {
return (NamedConstraint) super.withName(name);
}
@Override
public NamedConstraint withType(String type) {
return (NamedConstraint) super.withType(type);
}
@Override
public NamedConstraint withUsing(String using) {
return (NamedConstraint) super.withUsing(using);
}
@Override
public NamedConstraint withColumnsNames(List<String> list) {
return (NamedConstraint) super.withColumnsNames(list);
}
@Override
public NamedConstraint withColumns(List<ColumnParams> columns) {
return (NamedConstraint) super.withColumns(columns);
}
@Override
public NamedConstraint addColumns(ColumnParams... functionDeclarationParts) {
return (NamedConstraint) super.addColumns(functionDeclarationParts);
}
@Override
public NamedConstraint addColumns(Collection<? extends ColumnParams> functionDeclarationParts) {
return (NamedConstraint) super.addColumns(functionDeclarationParts);
}
@Override
public NamedConstraint withIndexSpec(List<String> idxSpec) {
return (NamedConstraint) super.withIndexSpec(idxSpec);
}
@Override
public NamedConstraint withIndexKeyword(String indexKeyword) {
return (NamedConstraint) super.withIndexKeyword(indexKeyword);
}
}