Class WildcardSourceType
- java.lang.Object
-
- com.tonic.analysis.source.ast.type.WildcardSourceType
-
- All Implemented Interfaces:
ASTNode,SourceType
public final class WildcardSourceType extends Object implements SourceType
A wildcard type argument such as "?", "? extends Number" or "? super Integer"; erases to java/lang/Object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWildcardSourceType.BoundKindWhich bound form a wildcard carries.
-
Constructor Summary
Constructors Constructor Description WildcardSourceType(WildcardSourceType.BoundKind boundKind, SourceType bound)Creates a wildcard type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.booleanequals(Object o)static WildcardSourceTypeextendsType(SourceType bound)Creates an upper-bounded wildcard.SourceTypegetBound()WildcardSourceType.BoundKindgetBoundKind()inthashCode()booleanhasLowerBound()booleanhasUpperBound()booleanisUnbounded()static WildcardSourceTypesuperType(SourceType bound)Creates a lower-bounded wildcard.IRTypetoIRType()Converts this source type to the equivalent IR type.StringtoJavaSource()Converts this source type to Java source code representation.StringtoString()static WildcardSourceTypeunbounded()-
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
-
WildcardSourceType
public WildcardSourceType(WildcardSourceType.BoundKind boundKind, SourceType bound)
Creates a wildcard type.- Parameters:
boundKind- which form of wildcard this isbound- the bound, required unless the kind is UNBOUNDED- Throws:
NullPointerException- if the bound kind is nullIllegalArgumentException- if a bounded kind is given no bound
-
-
Method Detail
-
unbounded
public static WildcardSourceType unbounded()
- Returns:
- a bare "?" wildcard
-
extendsType
public static WildcardSourceType extendsType(SourceType bound)
Creates an upper-bounded wildcard.- Parameters:
bound- the extends bound- Returns:
- the wildcard
- Throws:
IllegalArgumentException- if the bound is null
-
superType
public static WildcardSourceType superType(SourceType bound)
Creates a lower-bounded wildcard.- Parameters:
bound- the super bound- Returns:
- the wildcard
- Throws:
IllegalArgumentException- if the bound is null
-
getBoundKind
public WildcardSourceType.BoundKind getBoundKind()
- Returns:
- the bound kind
-
getBound
public SourceType getBound()
- Returns:
- the bound
-
isUnbounded
public boolean isUnbounded()
- Returns:
- true for a bare "?" wildcard
-
hasUpperBound
public boolean hasUpperBound()
- Returns:
- true for a "? extends" wildcard
-
hasLowerBound
public boolean hasLowerBound()
- Returns:
- true for a "? super" wildcard
-
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.
-
-