Class ConcreteTypeInfo

java.lang.Object
online.sharedtype.processor.domain.type.ReferableTypeInfo
online.sharedtype.processor.domain.type.ConcreteTypeInfo
All Implemented Interfaces:
Serializable, MappableType, TypeInfo

public final class ConcreteTypeInfo extends ReferableTypeInfo implements MappableType

Represents a general primitive type or object type that requires its target representation. Like String in typescript as "string", int in typescript as "number".

Type with typical signature and render pattern like array-like types are represented as other type info.

Author:
Cause Chung
See Also:
  • Constructor Details

    • ConcreteTypeInfo

      public ConcreteTypeInfo()
  • Method Details

    • ofPredefined

      public static ConcreteTypeInfo ofPredefined(String qualifiedName, String simpleName)
    • resolved

      public boolean resolved()
      Description copied from interface: TypeInfo

      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

      Specified by:
      resolved in interface TypeInfo
      Returns:
      true is this type and its dependency types are resolved.
    • reify

      public TypeInfo reify(Map<TypeVariableInfo,TypeInfo> mappings)
      Description copied from interface: TypeInfo
      Replace type variables with type arguments.
      Specified by:
      reify in interface TypeInfo
      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.
    • shallowResolved

      public boolean shallowResolved()
    • markShallowResolved

      public void markShallowResolved(TypeDef resolvedTypeDef)
    • typeDef

      public @Nullable TypeDef typeDef()
      Returns:
      null when the type is not resolved if it's a user defined type; or does not have a corresponding TypeDef, e.g. a predefined type.
    • qualifiedName

      public String qualifiedName()
      Specified by:
      qualifiedName in interface MappableType
    • mappedName

      public @Nullable String mappedName(@Nullable SharedType.TargetType targetType)
      Specified by:
      mappedName in interface MappableType
    • addMappedName

      public void addMappedName(SharedType.TargetType targetType, String mappedName)
      Specified by:
      addMappedName in interface MappableType
    • simpleName

      public String simpleName()
    • typeArgs

      public List<TypeInfo> typeArgs()
    • toString

      public String toString()
      Overrides:
      toString in class Object