-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaceDecl.java
More file actions
83 lines (66 loc) · 2.96 KB
/
Copy pathInterfaceDecl.java
File metadata and controls
83 lines (66 loc) · 2.96 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
package jtree.nodes;
import static jtree.util.Utils.*;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
@EqualsAndHashCode
@Getter @Setter
public class InterfaceDecl extends TypeDecl {
protected @NonNull List<GenericType> superInterfaces;
public InterfaceDecl(Name name, List<? extends Member> members) {
this(name, emptyList(), members);
}
public InterfaceDecl(Name name, Member... members) {
this(name, List.of(members));
}
public InterfaceDecl(Name name, List<GenericType> superInterfaces, List<? extends Member> members) {
this(name, emptyList(), superInterfaces, members, emptyList(), emptyList(), Optional.empty());
}
public InterfaceDecl(Name name, List<GenericType> superInterfaces, Member... members) {
this(name, superInterfaces, List.of(members));
}
public InterfaceDecl(Name name, List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) {
this(name, emptyList(), members, modifiers, annotations, docComment);
}
public InterfaceDecl(Name name, List<TypeParameter> typeParameters, List<? extends Member> members, List<Modifier> modifiers,
List<Annotation> annotations, Optional<String> docComment) {
this(name, typeParameters, emptyList(), members, modifiers, annotations, docComment);
}
public InterfaceDecl(Name name, List<TypeParameter> typeParameters, List<GenericType> superInterfaces,
List<? extends Member> members, List<Modifier> modifiers, List<Annotation> annotations, Optional<String> docComment) {
super(name, typeParameters, members, modifiers, annotations, docComment);
setSuperInterfaces(superInterfaces);
}
@Override
public InterfaceDecl clone() {
return new InterfaceDecl(getName(), clone(getTypeParameters()), clone(getSuperInterfaces()), clone(getMembers()), clone(getModifiers()), clone(getAnnotations()), getDocComment());
}
@Override
public String toCode() {
var superInterfaces = getSuperInterfaces();
return docString() + annotationString() + modifierString() + "interface " + getName() + typeParameterString()
+ (superInterfaces.isEmpty()? "" : " extends " + joinNodes(", ", superInterfaces))
+ " " + bodyString();
}
public void setSuperInterfaces(@NonNull List<GenericType> superInterfaces) {
this.superInterfaces = newList(superInterfaces);
}
public final void setSuperInterfaces(GenericType... superInterfaces) {
setSuperInterfaces(List.of(superInterfaces));
}
@Override
public <N extends INode> void accept(TreeVisitor visitor, Node parent, Consumer<N> replacer) {
if(visitor.visitInterfaceDecl(this, parent, cast(replacer))) {
getName().accept(visitor, this, this::setName);
visitList(visitor, getTypeParameters());
visitList(visitor, getSuperInterfaces());
visitList(visitor, getMembers());
visitList(visitor, getModifiers());
visitList(visitor, getAnnotations());
}
}
}