I'm currently working on a project where I need to group classes annotated with the @MainType and @SubType annotations. The @MainType annotation is applied to the superclass, while the @SubType annotation is applied to the subclasses.
I'm trying to achieve this using Kotlin reflection, but I haven't been successful so far.
Here's an example of what I'm trying to achieve:
@MainType
open class Animal {
// ...
}
@SubType("dog")
class Dog : Animal() {
// ...
}
@SubType("cat")
class Cat : Animal() {
// ...
}
I want to group the Dog and Cat classes under the Animal class, like so:
val typeTable = hashMapOf(
"Animal" to hashMapOf(
"dog" to Dog::class,
"cat" to Cat::class
)
)
I want to achieve this using reflection.
I'm not very familiar with using reflection in Kotlin, but I've tried playing around with it to achieve my goal. Still no success
Aucun commentaire:
Enregistrer un commentaire