aboutsummaryrefslogtreecommitdiffstats
path: root/javaparser-core/src/main/java/com/github/javaparser/ast/imports/StaticImportOnDemandDeclaration.java
blob: 534ddf69a088c74b3c0534b47db0aab938a18f4c (plain)
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 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.*;</code> <p><a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-7.html#jls-7.5.4">7.5.4.
 * Static-Import-on-Demand Declarations</a></p>
 */
public class StaticImportOnDemandDeclaration extends NonEmptyImportDeclaration {
    private ClassOrInterfaceType type;

    public StaticImportOnDemandDeclaration() {
        this(null, new ClassOrInterfaceType());
    }

    public StaticImportOnDemandDeclaration(Range range, ClassOrInterfaceType type) {
        super(range);
        setType(type);
    }

    @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 StaticImportOnDemandDeclaration setType(ClassOrInterfaceType type) {
        notifyPropertyChange(ObservableProperty.TYPE, this.type, type);
        this.type = assertNotNull(type);
        setAsParentNodeOf(type);
        return this;
    }

    @Override
    boolean isAsterisk() {
        return true;
    }

    @Override
    boolean isStatic() {
        return true;
    }
}