-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoStmt.java
More file actions
40 lines (32 loc) · 1012 Bytes
/
Copy pathDoStmt.java
File metadata and controls
40 lines (32 loc) · 1012 Bytes
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
package jtree.nodes;
import java.util.function.Consumer;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.NonNull;
@EqualsAndHashCode
@Getter @Setter
public class DoStmt extends Node implements CompoundStmt {
protected @NonNull Statement body;
protected @NonNull Expression condition;
public DoStmt(Statement body, Expression condition) {
setBody(body);
setCondition(condition);
}
@Override
public DoStmt clone() {
return new DoStmt(getBody().clone(), getCondition().clone());
}
@Override
public String toCode() {
var body = getBody();
return "do" + bodyString(body) + (body instanceof Block? " " : "\n") + "while(" + getCondition().toCode() + ");";
}
@Override
public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) {
if(visitor.visitDoStmt(this, parent, cast(replacer))) {
getBody().accept(visitor, this, this::setBody);
getCondition().accept(visitor, this, this::setCondition);
}
}
}