ConstructorInvocation


class ConstructorInvocation


Reflectively invokes the constructor of a declared class.

Summary

Public constructors

ConstructorInvocation(
    clazz: Class<Any!>,
    annotationClass: Class<Annotation!>?,
    parameterTypes: Array<Class<Any!>!>?
)

Creates a new ConstructorInvocation.

Public functions

Any!
invokeConstructor(constructorParams: Array<Any!>!)

Invokes the target constructor with the provided constructor parameters

Public constructors

ConstructorInvocation

ConstructorInvocation(
    clazz: Class<Any!>,
    annotationClass: Class<Annotation!>?,
    parameterTypes: Array<Class<Any!>!>?
)

Creates a new ConstructorInvocation.

Constructor lookup is either done using an annotation by passing the annotationClass as a parameter or through parameterTypes lookup. This class will attempt to lookup a constructor by first looking for a constructor annotated with annotationClass. If no constructors are found it will fallback and try to use parameterTypes.

Parameters
clazz: Class<Any!>

the declared class to create the instance off

annotationClass: Class<Annotation!>?

the annotation class to lookup the constructor

parameterTypes: Array<Class<Any!>!>?

array of parameter types to lookup a constructor on the declared class. The declared order of parameter types must match the order of the constructor parameters passed into invokeConstructor.

Public functions

invokeConstructor

fun invokeConstructor(constructorParams: Array<Any!>!): Any!

Invokes the target constructor with the provided constructor parameters

Parameters
constructorParams: Array<Any!>!

array of objects to be passed as arguments to the constructor

Returns
Any!

a new instance of the declared class