-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContinueStmt.java
More file actions
57 lines (44 loc) · 1.21 KB
/
Copy pathContinueStmt.java
File metadata and controls
57 lines (44 loc) · 1.21 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
package jtree.nodes;
import java.util.Optional;
import java.util.function.Consumer;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.NonNull;
@EqualsAndHashCode
@Getter @Setter
public class ContinueStmt extends Node implements Statement {
protected @NonNull Optional<Name> label;
public ContinueStmt() {
this(Optional.empty());
}
public ContinueStmt(Name label) {
this(Optional.ofNullable(label));
}
public ContinueStmt(Optional<Name> label) {
setLabel(label);
}
@Override
public ContinueStmt clone() {
return new ContinueStmt(clone(getLabel()));
}
@Override
public String toCode() {
return "continue" + getLabel().map(label -> " " + label.toCode()).orElse("") + ";";
}
public void setLabel(@NonNull Optional<Name> label) {
this.label = label;
}
public final void setLabel(Name label) {
setLabel(Optional.of(label));
}
public final void setLabel() {
setLabel(Optional.empty());
}
@Override
public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) {
if(visitor.visitContinueStmt(this, parent, cast(replacer))) {
getLabel().ifPresent(label -> label.<Name>accept(visitor, this, this::setLabel));
}
}
}