Interface JClassSymbol

    • Method Detail

      • getBinaryName

        @NonNull String getBinaryName()
        Returns the binary name of this type, as specified by the JLS: the JLS. For array types this returns the binary name of the component followed by "[]". This differs from Class.getName(), which for array types outputs an internal name.

        For example:

        
         int.class.getName() == "int"
         int[].class.getName() == "[I"
         String.class.getName() == "java.lang.String"
         String[].class.getName() == "[Ljava.lang.String;"
         
        whereas
        
         symbolOf(int.class).getBinaryName() == "int"
         symbolOf(int[].class).getBinaryName() == "int[]"
         symbolOf(String.class).getBinaryName() == "java.lang.String"
         symbolOf(String[].class).getBinaryName() == "java.lang.String[]"
         
      • getEnclosingMethod

        @Nullable JExecutableSymbol getEnclosingMethod()
        Returns the method or constructor this symbol is declared in, if it represents a local class declaration.

        Notice, that this returns null also if this class is local to a class or instance initializer.

      • getDeclaredClass

        default @Nullable JClassSymbol getDeclaredClass​(String name)
        Returns a class with the given name defined in this class.
      • getDeclaredMethods

        List<JMethodSymbol> getDeclaredMethods()
        Returns the methods declared directly in this class. This excludes bridges and other synthetic methods.

        For an array type T[], to the difference of Class, this method returns a one-element list with the Object.clone() method, as if declared like so: public final T[] clone() {...}.

        See Also:
        Class.getDeclaredMethods()
      • getConstructors

        List<JConstructorSymbol> getConstructors()
        Returns the constructors declared by this class. This excludes synthetic constructors.

        For an array type T[], and to the difference of Class, this should return a one-element list with a constructor having the same modifiers as the array type, and a single int parameter.

        See Also:
        Class.getDeclaredConstructors()
      • getDeclaredFields

        List<JFieldSymbol> getDeclaredFields()
        Returns the fields declared directly in this class. This excludes synthetic fields.

        For arrays, and to the difference of Class, this should return a one-element list with the public final int length field.

        See Also:
        Class.getDeclaredFields()
      • getDeclaredField

        default @Nullable JFieldSymbol getDeclaredField​(String name)
        Returns a field with the given name defined in this class.
      • getEnumConstants

        default @NonNull List<JFieldSymbol> getEnumConstants()
        Returns a list with all enum constants. If this symbol does not represent an enum, returns an empty set. The returned list is a subset of getDeclaredFields(). The order of fields denotes the normal order of enum constants.
      • getSuperInterfaceTypes

        List<JClassType> getSuperInterfaceTypes​(Substitution substitution)
        Returns the list of super interface types, under the given substitution.
      • getSuperclassType

        @Nullable JClassType getSuperclassType​(Substitution substitution)
        Returns the superclass type, under the given substitution.
      • getSuperclass

        @Nullable JClassSymbol getSuperclass()
        Returns the superclass symbol if it exists. Returns null if this class represents the class Object, or a primitive type. If this symbol is an interface, returns the symbol for Object.
      • getSuperInterfaces

        List<JClassSymbol> getSuperInterfaces()
        Returns the direct super-interfaces of this class or interface symbol.
      • isAbstract

        default boolean isAbstract()
      • getArrayComponent

        @Nullable JTypeDeclSymbol getArrayComponent()
        Returns the component symbol, returns null if this is not an array.
      • isArray

        boolean isArray()
      • isPrimitive

        boolean isPrimitive()
      • isEnum

        boolean isEnum()
      • isRecord

        boolean isRecord()
      • isAnnotation

        boolean isAnnotation()
      • isLocalClass

        boolean isLocalClass()
      • isAnonymousClass

        boolean isAnonymousClass()
      • getAnnotationAttributeNames

        default org.pcollections.PSet<String> getAnnotationAttributeNames()
        Return the simple names of all annotation attributes. If this is not an annotation type, return an empty set.
      • getDefaultAnnotationAttributeValue

        default @Nullable SymbolicValue getDefaultAnnotationAttributeValue​(String attrName)
        Return the default value of the attribute if this is an annotation type with a default. Return null if this is not an annotation type, if there is no such attribute, or the attribute has no default value. If the name is in the attribute name set, then the null return value can only mean that the attribute exists but has no default value.
        Parameters:
        attrName - Attribute name
      • getAnnotationRetention

        default @Nullable RetentionPolicy getAnnotationRetention()
        Returns the retention policy of this annotation, if this is an annotation symbol. Otherwise returns null.
      • annotationAppliesTo

        default boolean annotationAppliesTo​(ElementType elementType)
        Return whether annotations of this annotation type apply to the given construct, as per the Target annotation. Return false if this is not an annotation.
      • isClass

        default boolean isClass()
        This returns true if this is not an interface, primitive or array.
      • getNestRoot

        default @NonNull JClassSymbol getNestRoot()
        Returns the toplevel class containing this class. If this is a toplevel class, returns this.
      • acceptVisitor

        default <R,​P> R acceptVisitor​(SymbolVisitor<R,​P> visitor,
                                            P param)
        Description copied from interface: JElementSymbol
        Dispatch to the appropriate visit method of the visitor and returns its result.
        Specified by:
        acceptVisitor in interface JElementSymbol