Interface IType

All Superinterfaces:
Serializable
All Known Subinterfaces:
IBlockClass, IBlockClassInternal, IBlockType, ICompilableType, ICompilableTypeInternal, ICompoundType, IConstructorType, IDefaultArrayType, IDynamicType, IEnhanceableType, IEnumType, IErrorType, IFileRepositoryBasedType, IFunctionType, IGosuArrayClass, IGosuClass, IGosuClassInternal, IGosuEnhancement, IGosuEnhancementInternal, IGosuFragment, IGosuProgram, IGosuProgramInternal, IGosuTemplateInternal, IInvocableType, IJavaArrayType, IJavaBackedType, IJavaEnumTypeInternal, IJavaType, IJavaTypeInternal, IMetaType, INamespaceType, INonLoadableType, IPropertiesType, ITemplateType, ITypeDeprecated, ITypeVariableArrayType, ITypeVariableType, Type<T>
All Known Implementing Classes:
AbstractType, AbstractTypeRef, BlockClass, BlockType, CompoundType, ConstructorType, DefaultArrayType, DefaultNonLoadableArrayType, DelegateFunctionType, DynamicType, ErrorType, ErrorTypeInfo.UniversalConstructorType, ErrorTypeInfo.UniversalFunctionType, FunctionArrayType, FunctionType, GosuArrayClass, GosuClass, GosuClassFragment, GosuEnhancement, GosuFragment, GosuProgram, GosuTemplateType, InnerClassCapableType, ITypeRef, JavaEnumType, JavaType, MetaType, NamespaceType, PackageType, ParameterizedFunctionType, PropertiesType, SyntheticClass, TypeBase, TypeInPackageType, TypeVariableArrayType, TypeVariableType

public interface IType extends Serializable
  • Field Details

    • EMPTY_TYPE_LIST

      static final ArrayList<IType> EMPTY_TYPE_LIST
    • EMPTY_TYPE_ARRAY

      static final IType[] EMPTY_TYPE_ARRAY
    • EMPTY_ARRAY

      static final IType[] EMPTY_ARRAY
  • Method Details

    • getName

      String getName()
      The fully qualified name of this intrinsic type.
    • getDisplayName

      String getDisplayName()
      The display name of this intrinsic type. Often this is simply the same as getName(), but in some cases a type may want to modify it's name for presentation to the user.
    • getRelativeName

      String getRelativeName()
      The relative or unqualified name. For a class this should be just the class name without the package name.
    • getNamespace

      String getNamespace()
      The namespace for this class. For a java class this will be the package, while for other types of intrinsic types it could be another logical name.
    • getTypeLoader

      ITypeLoader getTypeLoader()
      Returns the type loader responsible for loading this intrinsic type.
    • getSupertype

      IType getSupertype()
      Returns the type representing the supertype of this type. Returns null if this type has no supertype.
    • getEnclosingType

      IType getEnclosingType()
      Returns the type immediately enclosing this type. If this type is not enclosed, returns null.
    • getGenericType

      IType getGenericType()
      If this is a parameterized type, returns the generic type this type parameterizes. Otherwise, returns null.
    • isFinal

      boolean isFinal()
      True if this type cannot be extended.
    • isInterface

      boolean isInterface()
      Returns true if this type is an interface.
    • getFunctionalInterface

      default IFunctionType getFunctionalInterface()
    • isEnum

      boolean isEnum()
      Returns true if this type is an enumeration.
    • getInterfaces

      IType[] getInterfaces()
      Returns:
      If this is a class, returns a list of all the interfaces this type implements. Similarly, if this is an interface, returns a list of all the interfaces this type extends. In any case, returns an empty list if this type neither implements nor extends interfaces.
    • isParameterizedType

      boolean isParameterizedType()
      Returns true if this ia a Parameterized Type.

      Note a Parameterzied Type is not the same as a Generic Type. The difference is that a Parameterized Type is a concrete version of a Generic Type. For instance, the class ArrayList is a Generic Type, while the class ArrayList is a Parameterized Type of the the Generic Type ArrayList.

    • isGenericType

      boolean isGenericType()
      Returns true if this ia a Generic Type.
      See Also:
    • getGenericTypeVariables

      IGenericTypeVariable[] getGenericTypeVariables()
      Returns an array of GenericTypeVariables declared with this Generic Type. Otherwise, returns null if this is not a Generic Type.
    • getParameterizedType

      IType getParameterizedType(IType... ofType)
      Assuming this intrinsic type is a Generic type, return the parameterized type associated with the given list of type parameters. If the type has not been created yet, creates the parameterized type. Successive calls to this method having identical parameter types must return the identical parameterized type.
      Parameters:
      ofType - The type parameters.
      Returns:
      The concrete type associated with the type parameters.
    • getTypeParameters

      IType[] getTypeParameters()
      If this is a parameterized type, returns the specific types used to create this type, null otherwies.
    • getAllTypesInHierarchy

      Set<? extends IType> getAllTypesInHierarchy()
      Returns a Set of all IIntrinsicTypes that this class is assignable from, including this class. This includes implemented interfaces and superclasses, recursively up the hieararchy. For array types, this will be a Set of all types that its component type is assignable from.
    • isArray

      boolean isArray()
      True if this is an array.
    • isPrimitive

      boolean isPrimitive()
      True if this type represents a primitive type e.g., Java int, char, etc.
    • getArrayType

      IType getArrayType()
      Make an array type from this type. E.g., String -> String[]
    • makeArrayInstance

      Object makeArrayInstance(int iLength)
      Construct an array instance of specified length.
    • getArrayComponent

      Object getArrayComponent(Object array, int iIndex) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
      Returns the value of the indexed component in the specified array object.
      Parameters:
      array - An array instance of this intrinsic type.
      iIndex - The index of the component to get.
      Returns:
      The value of the indexed component in the specified array.
      Throws:
      NullPointerException - If the specified object is null,
      IllegalArgumentException - If the specified object is not an array.
      ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
    • setArrayComponent

      void setArrayComponent(Object array, int iIndex, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
      Sets the value of the indexed component in the specified array object.
      Parameters:
      array - An array instance of this intrinsic type.
      iIndex - The index of the component to set.
      value - The new value of the indexed component.
      Throws:
      NullPointerException - If the specified object is null,
      IllegalArgumentException - If the specified object is not an array.
      ArrayIndexOutOfBoundsException - If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
    • getArrayLength

      int getArrayLength(Object array) throws IllegalArgumentException
      Returns the length of the specified array object.
      Parameters:
      array - An array instance of this intrinsic type.
      Returns:
      The length of the array.
      Throws:
      IllegalArgumentException - If the object argument is not an array.
    • getComponentType

      IType getComponentType()
      If this is an array type, a type representing the component type of the array. Otherwise null.
    • isAssignableFrom

      boolean isAssignableFrom(IType type)
      Determines if the type represented by this intrinsic type is either the same as, or is a super-type of the type represented by the specified type parameter.
    • isMutable

      boolean isMutable()
      Are intances of this type mutable? Note sometimes it's difficult to determine. For instance, java classes don't contain any information about mutability. In which case we always assume mutable, even when the underlying type may in fact be immutable. E.g., even though java.lang.String is not mutable, its corresponding JavaIntrinsicType will say it is.
      Returns:
      True if this type is mutable.
    • getTypeInfo

      ITypeInfo getTypeInfo()
      Get the type information for this intrinsic type.
      See Also:
    • unloadTypeInfo

      void unloadTypeInfo()
      Unload or nullify any references to this IType's ITypeInfo.
    • readResolve

      Object readResolve() throws ObjectStreamException
      IType requires this method be implemented to ensure IType instances can be centrally defined and cached.
      Throws:
      ObjectStreamException
    • isValid

      boolean isValid()
      Defines this type if it is not yet fully defined. For instance, if this type has source code associated with it, it must fully compile the source for it to be fully defined.
      Returns:
      true if this type is valid.
    • getModifiers

      int getModifiers()
      Returns the modifiers for this type, encoded in an integer. The modifiers consist of the constants for public, protected, private, final, static, abstract they should be decoded using the methods of class Modifier.
      See Also:
    • isAbstract

      boolean isAbstract()
    • isDiscarded

      boolean isDiscarded()
      True if this type has been replaced with a newer version of the same name in the type system.
    • setDiscarded

      void setDiscarded(boolean bDiscarded)
    • isCompoundType

      boolean isCompoundType()
    • getCompoundTypeComponents

      Set<IType> getCompoundTypeComponents()
    • getMetaType

      IMetaType getMetaType()
    • getLiteralMetaType

      IMetaType getLiteralMetaType()
    • getSourceFiles

      default IFile[] getSourceFiles()
    • isDynamic

      default boolean isDynamic()
    • isCompilable

      default boolean isCompilable()
    • compile

      default byte[] compile()