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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
package com.github.javaparser.ast.modules;
import com.github.javaparser.Range;
import com.github.javaparser.ast.AllFieldsConstructor;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.expr.Name;
import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
import com.github.javaparser.ast.observer.ObservableProperty;
import com.github.javaparser.ast.visitor.CloneVisitor;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import com.github.javaparser.metamodel.JavaParserMetaModel;
import com.github.javaparser.metamodel.ModuleDeclarationMetaModel;
import java.util.Arrays;
import java.util.List;
import static com.github.javaparser.utils.Utils.assertNotNull;
import javax.annotation.Generated;
/**
* A Java 9 Jigsaw module declaration. <code>@Foo module com.github.abc { requires a.B; }</code>
*/
public class ModuleDeclaration extends Node implements NodeWithName<ModuleDeclaration>, NodeWithAnnotations<ModuleDeclaration> {
private Name name;
private NodeList<AnnotationExpr> annotations;
private boolean isOpen;
private NodeList<ModuleStmt> moduleStmts;
public ModuleDeclaration() {
this(null, new NodeList<>(), new Name(), false, new NodeList<>());
}
public ModuleDeclaration(Name name, boolean isOpen) {
this(null, new NodeList<>(), name, isOpen, new NodeList<>());
}
@AllFieldsConstructor
public ModuleDeclaration(NodeList<AnnotationExpr> annotations, Name name, boolean isOpen, NodeList<ModuleStmt> moduleStmts) {
this(null, annotations, name, isOpen, moduleStmts);
}
/**This constructor is used by the parser and is considered private.*/
@Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
public ModuleDeclaration(Range range, NodeList<AnnotationExpr> annotations, Name name, boolean isOpen, NodeList<ModuleStmt> moduleStmts) {
super(range);
setAnnotations(annotations);
setName(name);
setOpen(isOpen);
setModuleStmts(moduleStmts);
customInitialization();
}
@Override
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
return v.visit(this, arg);
}
@Override
public <A> void accept(VoidVisitor<A> v, A arg) {
v.visit(this, arg);
}
@Override
public Name getName() {
return name;
}
@Override
public ModuleDeclaration setName(final Name name) {
assertNotNull(name);
if (name == this.name) {
return (ModuleDeclaration) this;
}
notifyPropertyChange(ObservableProperty.NAME, this.name, name);
if (this.name != null)
this.name.setParentNode(null);
this.name = name;
setAsParentNodeOf(name);
return this;
}
@Override
public NodeList<AnnotationExpr> getAnnotations() {
return annotations;
}
@Override
public ModuleDeclaration setAnnotations(final NodeList<AnnotationExpr> annotations) {
assertNotNull(annotations);
if (annotations == this.annotations) {
return (ModuleDeclaration) this;
}
notifyPropertyChange(ObservableProperty.ANNOTATIONS, this.annotations, annotations);
if (this.annotations != null)
this.annotations.setParentNode(null);
this.annotations = annotations;
setAsParentNodeOf(annotations);
return this;
}
@Override
@Generated("com.github.javaparser.generator.core.node.GetNodeListsGenerator")
public List<NodeList<?>> getNodeLists() {
return Arrays.asList(getAnnotations(), getModuleStmts());
}
@Override
public boolean remove(Node node) {
if (node == null)
return false;
for (int i = 0; i < annotations.size(); i++) {
if (annotations.get(i) == node) {
annotations.remove(i);
return true;
}
}
for (int i = 0; i < moduleStmts.size(); i++) {
if (moduleStmts.get(i) == node) {
moduleStmts.remove(i);
return true;
}
}
return super.remove(node);
}
public boolean isOpen() {
return isOpen;
}
public ModuleDeclaration setOpen(final boolean isOpen) {
if (isOpen == this.isOpen) {
return (ModuleDeclaration) this;
}
notifyPropertyChange(ObservableProperty.OPEN, this.isOpen, isOpen);
this.isOpen = isOpen;
return this;
}
public NodeList<ModuleStmt> getModuleStmts() {
return moduleStmts;
}
public ModuleDeclaration setModuleStmts(final NodeList<ModuleStmt> moduleStmts) {
assertNotNull(moduleStmts);
if (moduleStmts == this.moduleStmts) {
return (ModuleDeclaration) this;
}
notifyPropertyChange(ObservableProperty.MODULE_STMTS, this.moduleStmts, moduleStmts);
if (this.moduleStmts != null)
this.moduleStmts.setParentNode(null);
this.moduleStmts = moduleStmts;
setAsParentNodeOf(moduleStmts);
return this;
}
@Override
@Generated("com.github.javaparser.generator.core.node.CloneGenerator")
public ModuleDeclaration clone() {
return (ModuleDeclaration) accept(new CloneVisitor(), null);
}
@Override
@Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator")
public ModuleDeclarationMetaModel getMetaModel() {
return JavaParserMetaModel.moduleDeclarationMetaModel;
}
}
|