swiftpoet / io.outfoxx.swiftpoet / DeclaredTypeName

DeclaredTypeName

class DeclaredTypeName : TypeName, Comparable<DeclaredTypeName>

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

Constructors

<init>

Returns a type name created from the given parts. For example, calling this with module name "Swift" and simple names "Array", "Iterator" yields Swift.Array.Iterator.

DeclaredTypeName(moduleName: String, simpleName: String, vararg simpleNames: String)

Properties

canonicalName

val canonicalName: String

compoundName

val compoundName: String

moduleName

Module name, like "Swift" for Array.Iterator.

val moduleName: String

simpleName

Simple name of this type, like "Iterator" for Swift.Array.Iterator.

val simpleName: String

simpleNames

val simpleNames: List<String>

Functions

compareTo

fun compareTo(other: DeclaredTypeName): Int

enclosingTypeName

Returns the enclosing type, like Map for Map.Entry. Returns null if this type is not nested in another type.

fun enclosingTypeName(): DeclaredTypeName?

nestedType

Returns a new DeclaredTypeName instance for the specified name as nested inside this type.

fun nestedType(name: String): DeclaredTypeName

peerType

Returns a type that shares the same enclosing package or type. If this type is enclosed by another type, this is equivalent to enclosingTypeName().nestedType(name). Otherwise it is equivalent to get(packageName(), name).

fun peerType(name: String): DeclaredTypeName

topLevelTypeName

Returns the top type in this nesting group. Equivalent to chained calls to DeclaredTypeName.enclosingTypeName until the result's enclosing type is null.

fun topLevelTypeName(): DeclaredTypeName

Companion Object Functions

typeName

fun typeName(qualifiedTypeName: String): DeclaredTypeName

Extension Functions

parameterizedBy

fun DeclaredTypeName.parameterizedBy(vararg typeArguments: TypeName): ParameterizedTypeName