Class GenericSourceType
- java.lang.Object
-
- com.tonic.analysis.source.ast.type.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 Summary
Constructors Constructor Description GenericSourceType(ReferenceSourceType rawType, List<SourceType> typeArguments)Creates a generic type over a copy of the type argument list.GenericSourceType(String className, SourceType... typeArguments)Creates a generic type from a class name and type arguments.GenericSourceType(String className, List<SourceType> typeArguments)Creates a generic type from a class name and a type argument list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.booleanequals(Object o)ReferenceSourceTypegetRawType()SourceTypegetTypeArgument(int index)intgetTypeArgumentCount()List<SourceType>getTypeArguments()inthashCode()IRTypetoIRType()Converts this source type to the equivalent IR type.StringtoJavaSource()Converts this source type to Java source code representation.StringtoString()-
Methods inherited from interface com.tonic.analysis.source.ast.ASTNode
deepClone, findAll, findAll, findAncestor, findFirst, findFirst, getChildren, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
Methods inherited from interface com.tonic.analysis.source.ast.type.SourceType
getLocation, getParent, isArray, isPrimitive, isReference, isVoid, setParent
-
-
-
-
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 typetypeArguments- 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 nametypeArguments- 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 nametypeArguments- the type arguments in order
-
-
Method Detail
-
getRawType
public ReferenceSourceType getRawType()
- Returns:
- the raw type
-
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:SourceTypeConverts this source type to Java source code representation.- Specified by:
toJavaSourcein interfaceSourceType- Returns:
- the Java source representation (e.g., "int", "String", "int[]")
-
toIRType
public IRType toIRType()
Description copied from interface:SourceTypeConverts this source type to the equivalent IR type.- Specified by:
toIRTypein interfaceSourceType- Returns:
- the corresponding IRType
-
accept
public <T> T accept(SourceVisitor<T> visitor)
Description copied from interface:ASTNodeAccepts a visitor for this node.
-
-