Interface TypeInfo

All Superinterfaces:
Serializable
All Known Implementing Classes:
ArrayTypeInfo, ConcreteTypeInfo, DateTimeInfo, MapTypeInfo, ReferableTypeInfo, TypeVariableInfo

public interface TypeInfo extends Serializable
Type information. Similar concept as TypeMirror.
Author:
Cause Chung
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TypeInfo
    Represents no type.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Mark this type as referenced by another type.
    default TypeInfo
    Replace type variables with type arguments.
    default boolean
    Check if this type and its dependency types are resolved.
  • Field Details

    • NO_TYPE_INFO

      static final TypeInfo NO_TYPE_INFO
      Represents no type. This can happen when a type is not visible, e.g. not on module path.
      See Also:
  • Method Details

    • resolved

      default boolean resolved()

      Check if this type and its dependency types are resolved.

      When parsing a type's structure, a dependency type is firstly captured as a TypeInfo. At this stage, because we don't know its output structure or if it needs to be output at all, we mark it as unresolved. Also, due to possible cyclic dependencies, the resolution stage needs to be performed after initial parsing state. During resolution, once a type is parsed, it's marked as resolved. Note that a type is marked as resolved when created, if it can be determined at that time.

      Object contains resolved flag as a mutable state

      Returns:
      true is this type and its dependency types are resolved.
    • reify

      default TypeInfo reify(Map<TypeVariableInfo,TypeInfo> mappings)
      Replace type variables with type arguments.
      Parameters:
      mappings - key is a type variable e.g. T value is a type argument, a concrete type e.g. Integer, or a generic type with concrete type parameter, e.g. Tuple<String, String>
      Returns:
      a newly created type info if updated.
    • addReferencingType

      void addReferencingType(TypeDef typeDef)
      Mark this type as referenced by another type. Used for e.g. cyclic reference detection.
      Parameters:
      typeDef - type that references this type