'Kotlin pass generic class type to callback and use as gson argument
Aim is to write a callback function and provide it generic class params
...execute(MyCallBack(Type caseAClass,Type caseBClass){
override fun onCaseAFound(CaseA data){}
override fun onCaseBFound(CaseB data){}
})
The CaseA and CaseB modals passed to the callback can be dynamic
I'm confused with TypeTokans, Generic types n whatnot
The Class which calls this callback uses Gson and passes the type specified in Callback to Gson with a string, creates object and calls appropriate callback's method with object of declared class aa param
Is this possible?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
