ensureInstance

fun <T : Any> ensureInstance(kclass: KClass<T>, obj: Any): T

Utility function - asserts that obj is an instance of kclass. Throws an exception if it is not or returns obj cast to T on success.

Parameters

kclass

The KClass of the expected type of obj.

obj

The object that should be tested.

T

The expected type of obj.