-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJoin.java
More file actions
75 lines (61 loc) · 1.81 KB
/
Copy pathJoin.java
File metadata and controls
75 lines (61 loc) · 1.81 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
package jaskell.sql;
import jaskell.script.Directive;
import jaskell.script.Parameter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
class Join implements Directive {
Directive _prefix;
Directive _join;
public On on(Predicate _on){
On re = new On();
re._join = this;
re._on.add(_on);
return re;
}
@Override
public String script() {
return String.format("%s JOIN %s", _prefix.script(), _join.script());
}
@Override
public List<Parameter<?>> parameters() {
List<Parameter<?>> re = _prefix.parameters();
re.addAll(_join.parameters());
return re;
}
public static class On extends Select.From implements CouldAlias, CouldUnion, CouldLimit, CouldOffset {
Join _join;
List<Predicate> _on = new ArrayList<>();
public On on(Predicate _on){
this._on.add(_on);
return this;
}
public Join join(Directive other){
Join re = new Join();
re._prefix = this;
re._join = other;
return re;
}
@Override
public String script() {
return String.format("%s ON %s", _join.script(),
_on.stream().map(Directive::script).collect(Collectors.joining(", ")));
}
@Override
public List<Parameter<?>> parameters() {
List<Parameter<?>> re = _join.parameters();
_on.forEach(item->re.addAll(item.parameters()));
return re;
}
public Group group() {
Group re = new Group();
re._prefix = this;
return re;
}
public Order order() {
Order re = new Order();
re._prefix = this;
return re;
}
}
}