swiftpoet / io.outfoxx.swiftpoet / TypeName

TypeName

abstract class TypeName

Any type in Swift's type system. This class identifies simple types like Int and String, composite types like Optional<String> and Set<String>, and unassignable types like Void.

Type names are dumb identifiers only and do not model the values they name. For example, the type name for Swift.Array doesn't know about the count property, the fact that arrays are collections, or even that it accepts a single type parameter.

Instances of this class are immutable value objects that implement equals() and hashCode() properly.

Defining new types

Create new reference types like MyModule.HelloWorld with DeclaredTypeName.typeName. To build composite types like Set<Long>, use the factory methods on ParameterizedTypeName and TypeVariableName.

Properties

name

open val name: String

optional

open val optional: Boolean

Functions

equals

open fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

makeNonOptional

open fun makeNonOptional(): TypeName

makeOptional

open fun makeOptional(): ParameterizedTypeName

toString

open fun toString(): String

unwrapOptional

open fun unwrapOptional(): TypeName

wrapOptional

open fun wrapOptional(): ParameterizedTypeName

Inheritors

ComposedTypeName

class ComposedTypeName : TypeName

DeclaredTypeName

A fully-qualified type name for top-level and member types.

class DeclaredTypeName : TypeName, Comparable<DeclaredTypeName>

FunctionTypeName

class FunctionTypeName : TypeName

ParameterizedTypeName

class ParameterizedTypeName : TypeName

SelfTypeName

class SelfTypeName : TypeName

TupleTypeName

class TupleTypeName : TypeName

TypeVariableName

class TypeVariableName : TypeName