forked from JSQLParser/JSqlParser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWithFunctionDeclaration.java
More file actions
107 lines (88 loc) · 2.89 KB
/
WithFunctionDeclaration.java
File metadata and controls
107 lines (88 loc) · 2.89 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
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2025 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.expression.Expression;
import java.io.Serializable;
import java.util.List;
public class WithFunctionDeclaration implements Serializable {
private String functionName;
private List<WithFunctionParameter> parameters;
private String returnType;
private Expression returnExpression;
public WithFunctionDeclaration() {}
public WithFunctionDeclaration(String functionName, List<WithFunctionParameter> parameters,
String returnType, Expression returnExpression) {
this.functionName = functionName;
this.parameters = parameters;
this.returnType = returnType;
this.returnExpression = returnExpression;
}
public String getFunctionName() {
return functionName;
}
public void setFunctionName(String functionName) {
this.functionName = functionName;
}
public List<WithFunctionParameter> getParameters() {
return parameters;
}
public void setParameters(List<WithFunctionParameter> parameters) {
this.parameters = parameters;
}
public String getReturnType() {
return returnType;
}
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public Expression getReturnExpression() {
return returnExpression;
}
public void setReturnExpression(Expression returnExpression) {
this.returnExpression = returnExpression;
}
public WithFunctionDeclaration withFunctionName(String functionName) {
this.setFunctionName(functionName);
return this;
}
public WithFunctionDeclaration withParameters(List<WithFunctionParameter> parameters) {
this.setParameters(parameters);
return this;
}
public WithFunctionDeclaration withReturnType(String returnType) {
this.setReturnType(returnType);
return this;
}
public WithFunctionDeclaration withReturnExpression(Expression returnExpression) {
this.setReturnExpression(returnExpression);
return this;
}
public StringBuilder appendTo(StringBuilder builder) {
builder
.append("FUNCTION ")
.append(functionName)
.append("(");
for (int i = 0; parameters != null && i < parameters.size(); i++) {
if (i > 0) {
builder.append(", ");
}
parameters.get(i).appendTo(builder);
}
return builder
.append(") RETURNS ")
.append(returnType)
.append(" RETURN ")
.append(returnExpression);
}
@Override
public String toString() {
return appendTo(new StringBuilder()).toString();
}
}