api / org.gradle.api.reflect / TypeOf

TypeOf

@Incubating abstract class TypeOf<T : Any>

Provides a way to preserve high-fidelity Type information on generic types. Capture a generic type with an anonymous subclass. For example:

new TypeOf<NamedDomainObjectContainer<ArtifactRepository>>() {}

Parameters

- Parameterized type

Since
3.5

Functions

equals

open fun equals(other: Any?): Boolean

getActualTypeArguments

open fun getActualTypeArguments(): MutableList<TypeOf<*>>

Returns the list of type arguments used in the construction of this parameterized type.

getComponentType

open fun getComponentType(): TypeOf<*>

Returns the component type of the array type this object represents.

getParameterizedTypeDefinition

open fun getParameterizedTypeDefinition(): TypeOf<*>

Returns an object that represents the type from which this parameterized type was constructed.

getSimpleName

open fun getSimpleName(): String

Simple name.

getUpperBound

open fun getUpperBound(): TypeOf<*>

Returns the first declared upper-bound of the wildcard type expression represented by this type.

hashCode

open fun hashCode(): Int

isArray

open fun isArray(): Boolean

Queries whether this object represents an array, generic or otherwise.

isAssignableFrom

fun isAssignableFrom(type: TypeOf<*>): Boolean
fun isAssignableFrom(type: Type): Boolean

Is this type assignable from the given type?

isParameterized

open fun isParameterized(): Boolean

Queries whether this object represents a parameterized type.

isPublic

open fun isPublic(): Boolean

Queries whether the type represented by this object is public (java.lang.reflect.Modifier#isPublic(int)).

isSimple

open fun isSimple(): Boolean

Queries whether this object represents a simple (non-composite) type, not an array and not a generic type.

isSynthetic

open fun isSynthetic(): Boolean

Queries whether this object represents a synthetic type as defined by Class#isSynthetic().

isWildcard

open fun isWildcard(): Boolean

Queries whether this object represents a wildcard type expression, such as ?, ? extends Number, or ? super Integer.

parameterizedTypeOf

open static fun parameterizedTypeOf(parameterizedType: TypeOf<*>, vararg typeArguments: TypeOf<*>): TypeOf<*>

Constructs a new parameterized type from a given parameterized type definition and an array of type arguments. For example, parameterizedTypeOf(new TypeOf<List<?>>() {}, new TypeOf<String>() {}) is equivalent to new TypeOf<List<String>>() {}, except both the parameterized type definition and type arguments can be dynamically computed.

toString

fun toString(): String

typeOf

open static fun <T : Any> typeOf(type: Class<T>): TypeOf<T>

Creates an instance of TypeOf for the given Class.

open static fun <T : Any> typeOf(type: Type): TypeOf<T>

Creates an instance of TypeOf for the given Type.