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
|
package com.github.javaparser.ast.imports;
import com.github.javaparser.Range;
import com.github.javaparser.ast.observing.ObservableProperty;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import static com.github.javaparser.utils.Utils.assertNotNull;
/**
* Example: <code>import static com.github.javaparser.JavaParser.parse;</code>
* In the example, "com.github.javaparser.JavaParser" is the type,
* and "parse" is the staticMember.
* <p><a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-7.html#jls-7.5.3">7.5.3. Single-Static-Import Declarations</a></p>
*/
public class SingleStaticImportDeclaration extends NonEmptyImportDeclaration {
private ClassOrInterfaceType type;
private String staticMember;
public SingleStaticImportDeclaration() {
this(null, new ClassOrInterfaceType(), "empty");
}
public SingleStaticImportDeclaration(Range range, ClassOrInterfaceType type, String staticMember) {
super(range);
setType(type);
setStaticMember(staticMember);
}
@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);
}
public ClassOrInterfaceType getType() {
return type;
}
public SingleStaticImportDeclaration setType(ClassOrInterfaceType type) {
notifyPropertyChange(ObservableProperty.TYPE, this.type, type);
this.type = assertNotNull(type);
setAsParentNodeOf(type);
return this;
}
public String getStaticMember() {
return staticMember;
}
public SingleStaticImportDeclaration setStaticMember(String staticMember) {
notifyPropertyChange(ObservableProperty.STATIC_MEMBER, this.staticMember, staticMember);
this.staticMember = assertNotNull(staticMember);
return this;
}
@Override
boolean isAsterisk() {
return false;
}
@Override
boolean isStatic() {
return true;
}
}
|