Reputation: 819
I can do something like this in C#
PropertyInfo propertyInfo = typeof(TEntity).GetProperties()
How to do the same in Kotlin
Upvotes: 1
Views: 1271
Reputation: 8096
Well JVM suffers from type-erasure at Runtime.
You cannot do that simply, but Kotlin provides reified
keywords for inline
functions to take advantage of
inline fun <reified T: Any> takeKClass() {
val reflection: KClass<T> = T::class
...
}
But keep in mind that inline functions are embedded into call-site at compilation, but however this is a good feature provided by Kotlin.
Upvotes: 2