Interface ASTAnyTypeDeclaration

    • Method Detail

      • getTypeMirror

        @NonNull JClassType getTypeMirror()
        Returns the generic type declaration of the declared type. Note that for anonymous classes, this returns a class type whose symbol is the actual anonymous class. Eg new Runnable() { void foo() { } void run() { } } would present both methods, ie not just be a Runnable. The ASTConstructorCall would have type Runnable though, not the anonymous class.
        Specified by:
        getTypeMirror in interface TypeNode
        Returns:
        The type mirror. Never returns null; if the type is unresolved, returns TypeSystem.UNKNOWN.
      • getSimpleName

        default @NonNull String getSimpleName()
        Returns the simple name of this type declaration. Returns the empty string if this is an anonymous class declaration.
      • getPackageName

        default String getPackageName()
        Returns the name of the package in which this class is declared.
      • getBinaryName

        @NonNull String getBinaryName()
        Returns the binary name of this type declaration. This is like Class.getName().
      • getCanonicalName

        @Nullable String getCanonicalName()
        Returns the canonical name of this class, if it exists. Otherwise returns null. This is like Class.getCanonicalName().

        A canonical name exists if all enclosing types have a canonical name, and this is neither a local class nor an anonymous class. For example:

        
         package p;
        
         public class A { // p.A
             class M { // p.A.M
                 {
                     class Local { // null, local class
                        class M2 {} // null, member of a local class
                     }
        
                     new Local() { // null, anonymous class
                        class M2 {} // null, member of an anonymous class
                     };
                 }
             }
        
         }
         
        So non-local/anonymous classes declared somewhere in a local/anonymous class also have no loc
      • isAbstract

        default boolean isAbstract()
        Returns true if this is an abstract type. Interfaces and annotations types are implicitly abstract.
        Specified by:
        isAbstract in interface AccessNode
      • getEnumConstants

        default NodeStream<ASTEnumConstant> getEnumConstants()
        Returns the enum constants declared by this enum. If this is not an enum declaration, returns an empty stream.
      • getRecordComponents

        default @Nullable ASTRecordComponentList getRecordComponents()
        Returns the record components declared by this class. If this is not a record declaration, returns null.
      • getDeclarations

        default NodeStream<ASTBodyDeclaration> getDeclarations()
        Retrieves the member declarations (fields, methods, classes, etc.) from the body of this type declaration.
      • getDeclarations

        default <T extends ASTBodyDeclarationNodeStream<T> getDeclarations​(Class<? extends T> klass)
        Returns the declarations of a particular type.
        Type Parameters:
        T - Type of the declarations
        Parameters:
        klass - Type of the declarations
      • getBody

        default ASTTypeBody getBody()
        Returns the body of this type declaration.
      • isNested

        default boolean isNested()
        Returns true if this type declaration is nested inside an interface, class or annotation.
      • isLocal

        default boolean isLocal()
        Returns true if the class is declared inside a block other than the body of another class, or the top level. Anonymous classes are not considered local. Only class declarations can be local. Local classes cannot be static.
      • isTopLevel

        default boolean isTopLevel()
        Returns true if this type is declared at the top-level of a file.
      • isInterface

        default boolean isInterface()
        Returns true if this is an interface type declaration (including annotation types). This is consistent with Class.isInterface().
      • isRegularClass

        default boolean isRegularClass()
        Returns true if this is a regular class declaration (not an enum, not a record, not an interface or annotation). Note that eg JClassSymbol.isClass() counts records and enums in, just like isInterface() counts annotations in.
      • isRegularInterface

        default boolean isRegularInterface()
        Returns true if this is a regular interface declaration (not an annotation). Note that isInterface() counts annotations in.
      • getSuperInterfaceTypeNodes

        default @NonNull NodeStream<ASTClassOrInterfaceType> getSuperInterfaceTypeNodes()
        Returns the list of interfaces implemented by this class, or extended by this interface. Returns null if no such list is declared.