-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathAssertStatement.java
More file actions
81 lines (67 loc) · 2.08 KB
/
Copy pathAssertStatement.java
File metadata and controls
81 lines (67 loc) · 2.08 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
/*-
* #%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 net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
/**
* BigQuery's {@code ASSERT expression [AS description]}, which fails the script when the expression
* does not evaluate to {@code TRUE}.
*
* @see <a href=
* "https://cloud.google.com/bigquery/docs/reference/standard-sql/debugging-statements">Debugging
* statements</a>
*/
public class AssertStatement implements Statement {
private Expression expression;
private StringValue description;
public AssertStatement() {}
public AssertStatement(Expression expression) {
this.expression = expression;
}
public AssertStatement(Expression expression, StringValue description) {
this.expression = expression;
this.description = description;
}
public Expression getExpression() {
return expression;
}
public void setExpression(Expression expression) {
this.expression = expression;
}
public AssertStatement withExpression(Expression expression) {
setExpression(expression);
return this;
}
public StringValue getDescription() {
return description;
}
public void setDescription(StringValue description) {
this.description = description;
}
public AssertStatement withDescription(StringValue description) {
setDescription(description);
return this;
}
public StringBuilder appendTo(StringBuilder builder) {
builder.append("ASSERT ").append(expression);
if (description != null) {
builder.append(" AS ").append(description);
}
return builder;
}
@Override
public String toString() {
return appendTo(new StringBuilder()).toString();
}
@Override
public <T, S> T accept(StatementVisitor<T> statementVisitor, S context) {
return statementVisitor.visit(this, context);
}
}