-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathConflict.java
More file actions
149 lines (121 loc) · 3.42 KB
/
Copy pathConflict.java
File metadata and controls
149 lines (121 loc) · 3.42 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
package jaskell.sql;
import jaskell.script.Directive;
import jaskell.script.Parameter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Conflict implements Directive {
Directive _prefix;
List<Name> _items = new ArrayList<>();
Conflict(){
}
Conflict(String names){
_items.addAll(Arrays.stream(
names.split(",")).map(String::trim).map(Name::new).collect(Collectors.toList()));
}
Conflict(String... names){
_items.addAll(Arrays.stream(names).map(Name::new).collect(Collectors.toList()));
}
@Override
public String script() {
if(_items.isEmpty()) {
return String.format("%s CONFLICT", _prefix.script());
} else {
return String.format("%s CONFLICT (%s)",
_prefix.script(),
_items.stream().map(Name::script).collect(Collectors.joining(", ")));
}
}
@Override
public List<Parameter<?>> parameters() {
return _prefix.parameters();
}
public Do do_() {
Do re = new Do();
re._prefix = this;
return re;
}
public On on(){
On re = new On();
re._prefix = this;
return re;
}
public Where where(String name){
Where re = new Where(name);
re._prefix = this;
return re;
}
public Where where(Name name){
Where re = new Where(name);
re._prefix = this;
return re;
}
public static class On implements Directive{
Directive _prefix;
@Override
public String script() {
return String.format("%s ON", _prefix.script());
}
@Override
public List<Parameter<?>> parameters() {
return _prefix.parameters();
}
public Constraint constraint(String name){
Constraint re = new Constraint(name);
re._prefix = this;
return re;
}
public Constraint constraint(Literal name){
Constraint re = new Constraint(name);
re._prefix = this;
return re;
}
}
public static class Constraint implements Directive {
Directive _prefix;
Literal _constraint;
Constraint(String name){
_constraint = new Literal(name);
}
Constraint(Literal name){
_constraint = name;
}
@Override
public String script() {
return String.format("%s CONSTRAINT %s", _prefix.script(), _constraint);
}
@Override
public List<Parameter<?>> parameters() {
return _prefix.parameters();
}
public Do do_(){
Do re = new Do();
re._prefix = this;
return re;
}
}
public static class Where extends Statement {
Directive _prefix;
Name _name;
Where(String name){
_name = new Name(name);
}
Where(Name name){
_name = name;
}
@Override
public String script() {
return String.format("%s WHERE %s", _prefix.script(), _name.script());
}
@Override
public List<Parameter<?>> parameters() {
return _prefix.parameters();
}
public Do do_() {
Do re = new Do();
re._prefix = this;
return re;
}
}
}