Class Type

java.lang.Object
net.codecrete.windowsapi.metadata.Type
Direct Known Subclasses:
Array, ComInterface, Delegate, EnumType, Pointer, Primitive, Struct, TypeAlias

public abstract sealed class Type extends Object permits Struct, Delegate, Primitive, Pointer, Array, TypeAlias, EnumType, ComInterface
Base class for types.
  • Field Details

    • name

      protected String name
      The type name.
    • nativeName

      protected final String nativeName
      The native type name.
    • namespace

      protected final Namespace namespace
      The namespace this type belongs to.

      Not set for nested types.

    • typeDefIndex

      protected final int typeDefIndex
      The TypeDef index in the metadata file.
    • documentationUrl

      protected LazyString documentationUrl
      The documentation URL.
  • Constructor Details

    • Type

      protected Type(String name, Namespace namespace, int typeDefIndex)
      Creates a new instance.
      Parameters:
      name - the type name
      namespace - the type's namespace (or null if the type is an anonymous and/or nested type
      typeDefIndex - the TypeDef index
  • Method Details

    • name

      public final String name()
      Gets the type name.

      For architecture-specific types, this is the modified type name, as used for Java code.

      Returns:
      type name
    • setName

      public final void setName(String name)
      Sets the type name.
      Parameters:
      name - type name
    • nativeName

      public final String nativeName()
      Gets the native type name.

      For architecture-specific types, this is the original type name used by Windows.

      Returns:
      native type name
    • namespace

      public final Namespace namespace()
      Gets the type's namespace.

      Types enclosed in other types do not have a namespace.

      Returns:
      namespace
    • typeDefIndex

      public final int typeDefIndex()
      Gets the TypeDef index
      Returns:
      the index
    • isAnonymous

      public final boolean isAnonymous()
      Indicates if this type is anonymous, i.e., has an artificial name only.

      Only types enclosed in other types can be anonymous.

      Returns:
      if the type is anonymous
    • documentationUrl

      public final LazyString documentationUrl()
      Returns the URL to Microsoft's documentation about this type.
      Returns:
      the URL
    • setDocumentationUrl

      public final void setDocumentationUrl(LazyString documentationUrl)
      Sets the URL to Microsoft's documentation about this type.
      Parameters:
      documentationUrl - the URL
    • referencedTypes

      public Stream<Type> referencedTypes()
      Returns the types directly references by this type.
      Returns:
      Stream of types
    • replaceTypes

      public void replaceTypes(UnaryOperator<Type> typeReplacement)
      Replace the types directly referenced by this type with the provided replacements.

      The lambda for replacement lookup will return the same type if no replacement is needed.

      Parameters:
      typeReplacement - lambda for looking up the replacement type.