storio icon indicating copy to clipboard operation
storio copied to clipboard

Add marker interface for pojos that can be put/get

Open ZakTaccardi opened this issue 9 years ago • 4 comments

Could help a bit with type safety

storIo.put()
                .`object`(sqlData) //should fail to compile if `SqlData` does not implement the marker interface
                .prepare()
                .executeAsBlocking()

ZakTaccardi avatar Nov 29 '16 20:11 ZakTaccardi

Hm, interesting idea, but it will forbid you from working with classes that you don't control but have custom adapters for, like classes from libraries.

@nikitin-da thoughts?

artem-zinnatullin avatar Nov 29 '16 22:11 artem-zinnatullin

@artem-zinnatullin agreed, I can see how that can be a limitation that would outweigh the benefit for users relying on that flexibility.

Here's the use case I was hoping this would solve: I convert my StorIo POJOs into a Kotlin data class, and sometimes I forget to convert the Kotlin data class into the StorIo POJO on put operations.

ZakTaccardi avatar Nov 29 '16 23:11 ZakTaccardi

Yeah, I understand your pain, I catch myself everytime with same problem using Gson and other similar libraries, so I really like your proposal, but we have to check how many users may be affected by such change, since it's not backward compatible at all…

artem-zinnatullin avatar Nov 29 '16 23:11 artem-zinnatullin

Good idea to move this check to compile time, but marker interface itself will not force you to add type mapping. It looks like excess step and it will be impossible to use entities from libraries =(

nikitin-da avatar Nov 30 '16 08:11 nikitin-da