MarkRS
03/31/2023, 4:09 PMRuckus
03/31/2023, 4:14 PMfun doTheThing(resource: ResourceStringDesc, ...): ...
fun doTheThing(resource: ResourceFormattedStringDesc, ...): ...
MarkRS
03/31/2023, 4:16 PMRuckus
03/31/2023, 4:23 PMsealed class ResourceDesc
class ResourceStringDesc : ResourceDesc()
class ResourceFormattedStringDesc : ResourceDesc()
fun doTheThing(resource: ResourceDesc)
If you don't you could do the same thing with wrappers, and just include some helpers:
sealed class ResourceDescWrapper
class ResourceStringDescWrapper(val original: ResourceStringDesc) : ResourceDescWrapper()
class ResourceFormattedStringDescWrapper(val original: ResourceFormattedStringDesc) : ResourceDescWrapper()
fun doTheThing(resource: ResourceDescWrapper)
fun doTheThing(resource: ResourceStringDesc) = doTheThing(ResourceStringDescWrapper(resource))
fun doTheThing(resource: ResourceFormattedStringDesc) = doTheThing(ResourceFormattedStringDescWrapper(resource))
That might help clean up the chain, but depends on your use case.MarkRS
03/31/2023, 4:26 PMWout Werkman
03/31/2023, 4:27 PMMarkRS
03/31/2023, 4:44 PMMarkRS
03/31/2023, 4:51 PMWout Werkman
03/31/2023, 4:52 PMMarkRS
03/31/2023, 4:54 PMsciack
03/31/2023, 4:59 PMMarkRS
03/31/2023, 5:00 PMRuckus
03/31/2023, 5:26 PMproduceString
function that both ResourceStringDesc
and ResourceFormattedStringDesc
inherit from. Then your doTheThing
function takes the interface as a parameter.
https://pl.kotl.in/0buyunEgN