blob: 17f3d3f4302cfa392ce95709940e547f9a57a29d (
plain)
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
|
package org.zwobble.couscous.backends.python.ast;
import com.google.common.collect.ImmutableList;
import org.zwobble.couscous.backends.python.ast.visitors.PythonNodeVisitor;
import java.util.List;
public final class PythonClassNode implements PythonStatementNode {
public static Builder builder(String name) {
return new Builder(name);
}
public static class Builder {
private final String name;
private final ImmutableList.Builder<PythonStatementNode> statements;
public Builder(String name) {
this.name = name;
this.statements = ImmutableList.builder();
}
public PythonClassNode build() {
return new PythonClassNode(name, new PythonBlock(statements.build()));
}
public Builder statement(PythonStatementNode statement) {
statements.add(statement);
return this;
}
}
public static PythonClassNode pythonClass(String name, List<? extends PythonStatementNode> body) {
return pythonClass(name, new PythonBlock(body));
}
public static PythonClassNode pythonClass(final String name, final PythonBlock body) {
return new PythonClassNode(name, body);
}
private final String name;
private final PythonBlock body;
@Override
public void accept(PythonNodeVisitor visitor) {
visitor.visit(this);
}
private PythonClassNode(final String name, final PythonBlock body) {
this.name = name;
this.body = body;
}
public String getName() {
return this.name;
}
public PythonBlock getBody() {
return this.body;
}
@java.lang.Override
public java.lang.String toString() {
return "PythonClassNode(name=" + this.getName() + ", body=" + this.getBody() + ")";
}
}
|