Given this generic interface:
interface Trick<I, T> {
fun perform(input: I): T
}
I want to get a List of all classes implementing this interface, like this:
fun <I,T>loadTricks(): List<Trick<I, T>>
I already tried to use Google's Auto-Service library but all I was able to get was a list of type List<Trick<*, *>!>
, which I think will be a problem as I desired to preserve the visibility on the actual type each implementation uses.
I've also came across the Reflections library, but that one is no longer being actively supported and, as such, I'd like to avoid it.
Maybe I am even going the wrong way about all this, so I'll just explain what I am aiming to achieve:
- I want a list of all Tricks preserving the information of what Trick each of them is, the input I need to pass to "perform" and what output to expect from it.
Aucun commentaire:
Enregistrer un commentaire