-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathRoutineReference.java
More file actions
115 lines (95 loc) · 2.93 KB
/
Copy pathRoutineReference.java
File metadata and controls
115 lines (95 loc) · 2.93 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
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2026 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;
import java.util.List;
import java.util.stream.Collectors;
import net.sf.jsqlparser.statement.create.table.ColDataType;
import java.io.Serializable;
public class RoutineReference implements Serializable {
private String name;
private List<Argument> arguments;
private boolean allArguments;
private List<Argument> orderByArguments;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Argument> getArguments() {
return arguments;
}
public void setArguments(List<Argument> arguments) {
this.arguments = arguments;
}
public boolean isAllArguments() {
return allArguments;
}
public void setAllArguments(boolean allArguments) {
this.allArguments = allArguments;
}
public List<Argument> getOrderByArguments() {
return orderByArguments;
}
public void setOrderByArguments(List<Argument> orderByArguments) {
this.orderByArguments = orderByArguments;
}
/** A signature argument is a data type, not an invocation expression. */
public static class Argument implements Serializable {
public enum Mode {
IN, OUT, INOUT, VARIADIC
}
private Mode mode;
private String name;
private ColDataType dataType;
public Mode getMode() {
return mode;
}
public void setMode(Mode mode) {
this.mode = mode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ColDataType getDataType() {
return dataType;
}
public void setDataType(ColDataType dataType) {
this.dataType = dataType;
}
@Override
public String toString() {
return (mode == null ? "" : mode + " ") + (name == null ? "" : name + " ") + dataType;
}
}
@Override
public String toString() {
if (arguments == null && !allArguments && orderByArguments == null) {
return name;
}
StringBuilder sql = new StringBuilder(name).append('(');
if (allArguments) {
sql.append('*');
} else if (arguments != null) {
sql.append(arguments.stream().map(Object::toString).collect(Collectors.joining(", ")));
}
if (orderByArguments != null) {
if (arguments != null && !arguments.isEmpty()) {
sql.append(' ');
}
sql.append("ORDER BY ").append(orderByArguments.stream().map(Object::toString)
.collect(Collectors.joining(", ")));
}
return sql.append(')').toString();
}
}