Class ReferenceSourceType

  • All Implemented Interfaces:
    ASTNode, SourceType

    public final class ReferenceSourceType
    extends Object
    implements SourceType
    Represents a reference type (class or interface) in the source AST.
    • Constructor Detail

      • ReferenceSourceType

        public ReferenceSourceType​(String internalName)
        Creates a raw reference type printed by its simple name.
        Parameters:
        internalName - the class name in internal format
        Throws:
        NullPointerException - if internalName is null
      • ReferenceSourceType

        public ReferenceSourceType​(String internalName,
                                   List<SourceType> typeArguments)
        Creates a parameterized reference type printed by its simple name.
        Parameters:
        internalName - the class name in internal format
        typeArguments - the generic arguments, or null for none
        Throws:
        NullPointerException - if internalName is null
      • ReferenceSourceType

        public ReferenceSourceType​(String internalName,
                                   List<SourceType> typeArguments,
                                   boolean useSimpleName)
        Creates a reference type, choosing how the name is printed.
        Parameters:
        internalName - the class name in internal format
        typeArguments - the generic arguments, or null for none
        useSimpleName - true to print the simple name, false for the qualified one
        Throws:
        NullPointerException - if internalName is null
    • Method Detail

      • getInternalName

        public String getInternalName()
        Returns:
        the internal name
      • getTypeArguments

        public List<SourceType> getTypeArguments()
        Returns:
        the type arguments
      • isUseSimpleName

        public boolean isUseSimpleName()
        Returns:
        whether use simple name
      • getFullyQualifiedName

        public String getFullyQualifiedName()
        Gets the fully qualified name in Java format (e.g., "java.lang.String", or "Outer.Inner" for a nested class).
        Returns:
        the dotted source-form name
      • getSimpleName

        public String getSimpleName()
        Gets the simple class name (e.g., "String").
        Returns:
        the name with the package stripped
      • getPackageName

        public String getPackageName()
        Gets the package name (e.g., "java.lang").
        Returns:
        the dotted package name, empty for the default package
      • hasTypeArguments

        public boolean hasTypeArguments()
        Checks if this type has generic type arguments.
        Returns:
        true when at least one type argument is present
      • withTypeArguments

        public ReferenceSourceType withTypeArguments​(List<SourceType> typeArgs)
        Creates a copy of this type carrying different type arguments.
        Parameters:
        typeArgs - the type arguments for the copy
        Returns:
        a new type with the same internal name and simple-name preference
      • toJavaSource

        public String toJavaSource()
        Description copied from interface: SourceType
        Converts this source type to Java source code representation.
        Specified by:
        toJavaSource in interface SourceType
        Returns:
        the Java source representation (e.g., "int", "String", "int[]")
      • toIRType

        public IRType toIRType()
        Description copied from interface: SourceType
        Converts this source type to the equivalent IR type.
        Specified by:
        toIRType in interface SourceType
        Returns:
        the corresponding IRType
      • accept

        public <T> T accept​(SourceVisitor<T> visitor)
        Description copied from interface: ASTNode
        Accepts a visitor for this node.
        Specified by:
        accept in interface ASTNode
        Type Parameters:
        T - the return type of the visitor
        Parameters:
        visitor - the visitor to accept
        Returns:
        the result from the visitor
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object