Package com.episode6.mockspresso2.reflect

Types

Link copied to clipboard
class JvmTypeResolutionError(message: String) : AssertionError
Link copied to clipboard
class MultipleQualifierError(context: String) : AssertionError

Thrown if ore than one qualifier annotation is found on a given class.

Link copied to clipboard
class TypeTokenResolutionError(referencedType: KType, context: <Error class: unknown class><out <Error class: unknown class>>) : AssertionError

Thrown when an error occurs while trying to resolve a KType into a concrete TypeToken

Functions

Link copied to clipboard
expect fun KClass<*>.allConstructors(): List<KFunction<*>>

Returns a list of all constructors for a KClass

actual fun KClass<*>.allConstructors(): List<KFunction<*>>
Link copied to clipboard
fun <T> TypeToken<T>.asJClass(): Class<T>

Return the Class for this TypeToken.

Link copied to clipboard
fun <Error class: unknown class><out <Error class: unknown class>>.asKClass(): KClass<*>

Return the KClass for this TypeToken. Class is not typed to ensure support for TypeTokens of nullable types.

Link copied to clipboard
expect fun KFunction<*>.callWith(vararg args: Any?): Any?

Call the receiver KFunction with the provided args

actual fun KFunction<*>.callWith(vararg args: Any?): Any?
Link copied to clipboard
expect fun KClass<*>.createConcreteType(arguments: List<KTypeProjection>, nullable: Boolean): KType

Creates a concrete type of the receiver KClass using the provided arguments to fill in any type parameters.

actual fun KClass<*>.createConcreteType(arguments: List<KTypeProjection>, nullable: Boolean): KType
Link copied to clipboard
fun List<Annotation>.findQualifier(errorContext: () -> String): Annotation?

Returns the single qualifier in the receiver list if there is one. Throws a MultipleQualifierError if there is more than one qualifier.

Link copied to clipboard
expect fun Annotation.isQualifier(): Boolean

Returns true if the receiver is a qualifier annotation

actual fun Annotation.isQualifier(): Boolean
Link copied to clipboard
expect fun KFunction<*>.parameterCount(): Int

Returns the number of parameters for a given KFunction

actual fun KFunction<*>.parameterCount(): Int
Link copied to clipboard
expect fun KFunction<*>.parameterKeys(context: <Error class: unknown class><out <Error class: unknown class>>): List<<Error class: unknown class><out <Error class: unknown class>>>

Returns a list of DependencyKeys that represent the parameters of the receiver KFunction.

Link copied to clipboard
expect fun KClass<*>.primaryConstructor(): KFunction<*>

Returns the primary constructor for a KClass

actual fun KClass<*>.primaryConstructor(): KFunction<*>
Link copied to clipboard
fun TypeToken<*>.resolveJvmType(jvmType: Type, declaringClass: Class<*>): TypeToken<*>

Returns a concrete TypeToken representing the given jvmType.

Link copied to clipboard
fun <Error class: unknown class><out <Error class: unknown class>>.resolveType(referencedType: KType): <Error class: unknown class><out <Error class: unknown class>>

Returns a concrete TypeToken representing the referencedType using the receiver as context.

Link copied to clipboard
expect fun KCallable<*>.tryMakeAccessible()

Tries to make a KFunction accessible if it is not already

actual fun KCallable<*>.tryMakeAccessible()
Link copied to clipboard
expect fun KClass<*>.typeParameters(): List<KTypeParameter>

Returns a list of type parameters for the receiver KClass

actual fun KClass<*>.typeParameters(): List<KTypeParameter>