Class GenericSourceType

  • All Implemented Interfaces:
    ASTNode, SourceType

    public final class GenericSourceType
    extends Object
    implements SourceType
    A parameterized reference type such as List<String>; the type arguments are source-only and erase away in toIRType.
    • Constructor Detail

      • GenericSourceType

        public GenericSourceType​(ReferenceSourceType rawType,
                                 List<SourceType> typeArguments)
        Creates a generic type over a copy of the type argument list.
        Parameters:
        rawType - the erased reference type
        typeArguments - the type arguments in order
        Throws:
        NullPointerException - if either argument is null
      • GenericSourceType

        public GenericSourceType​(String className,
                                 List<SourceType> typeArguments)
        Creates a generic type from a class name and a type argument list.
        Parameters:
        className - the raw class name
        typeArguments - the type arguments in order
        Throws:
        NullPointerException - if the type argument list is null
      • GenericSourceType

        public GenericSourceType​(String className,
                                 SourceType... typeArguments)
        Creates a generic type from a class name and type arguments.
        Parameters:
        className - the raw class name
        typeArguments - the type arguments in order
    • Method Detail

      • getTypeArguments

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

        public int getTypeArgumentCount()
        Returns:
        the number of type arguments
      • getTypeArgument

        public SourceType getTypeArgument​(int index)
        Parameters:
        index - position in the type argument list
        Returns:
        the type argument at that position
        Throws:
        IndexOutOfBoundsException - if the index is out of range
      • 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