Class DeclaredType

java.lang.Object
org.checkerframework.afu.scenelib.type.Type
org.checkerframework.afu.scenelib.type.DeclaredType

public class DeclaredType extends Type
A Java type with optional type parameters and inner type. For example:
   type
   type<type parameters>.inner type
 
A DeclaredType can represent a wildcard by using "?" as the name. If this type is a wildcard, it is illegal to call addTypeParameter(Type), getTypeParameter(int), getTypeParameters(), setInnerType(DeclaredType), getInnerType(), and setTypeParameters(List). If called, an IllegalStateException will be thrown.

Types are stored with the outer most type at the top of the type tree. This is opposite to the way types are stored in javac.

  • Field Details

  • Constructor Details

    • DeclaredType

      public DeclaredType(String name)
      Creates a new declared type with no type parameters or inner type.
      Parameters:
      name - the raw, un-annotated name of this type, or "?" for a wildcard
    • DeclaredType

      public DeclaredType()
      Creates a new declared type with an empty name and no type parameters or inner type.
  • Method Details

    • setName

      public void setName(String name)
      Sets the raw, un-annotated name of this type.
      Parameters:
      name - the name
    • getName

      public String getName()
      Gets the raw, un-annotated name of this type.
      Returns:
      the name
    • addTypeParameter

      public void addTypeParameter(Type typeParameter)
      Adds the given type parameter to this type.
      Parameters:
      typeParameter - the type parameter
    • setTypeParameters

      public void setTypeParameters(List<Type> typeParameters)
      Sets the type parameters of this type.
      Parameters:
      typeParameters - the type parameters
    • getTypeParameter

      public Type getTypeParameter(int index)
      Gets the type parameter at the given index.
      Parameters:
      index - the index
      Returns:
      the type parameter
    • getTypeParameters

      public List<Type> getTypeParameters()
      Gets a copy of the type parameters of this type. This will be empty if there are none.
      Returns:
      the type parameters
    • setInnerType

      public void setInnerType(DeclaredType innerType)
      Sets the inner type.
      Parameters:
      innerType - the inner type
    • getInnerType

      public DeclaredType getInnerType()
      Gets the inner type. This will be null if there is none.
      Returns:
      the inner type or null
    • getKind

      public Type.Kind getKind()
      Description copied from class: Type
      Gets the Type.Kind of this Type.
      Specified by:
      getKind in class Type
      Returns:
      the kind
    • isWildcard

      public boolean isWildcard()
      Determines if this type is a wildcard.
      Returns:
      true if this type is a wildcard, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object