epam / CoroutinesCache

In mobile development exists solution for caching with RxJava usage, but there is no solutions for Kotlin Coroutines. The project is to provide this functionality to mobile community.
Apache License 2.0
162 stars 7 forks source link

Issue 11 entry serialization type #14

Closed LikeAnyan closed 5 years ago

LikeAnyan commented 5 years ago

Added @EntryClass annotation that is used in @ProviderKey annotation to tell type that should be used for object serialization & deserialization. Pr links this issue: https://github.com/epam/CoroutinesCache/issues/11. @EntryClass annotation has two params - first called rawType, kotlin class should be passed there, the second one - called type params with type vararg of EntryClass (used as type arguments for ParameterizedType). Here's usage examples:

@ProviderKey("key1", EntryClass(Data::class))
fun getData(data: Deferred<Data>): Deferred<Data>

@ProviderKey("key2", EntryClass(List::class, EntryClass(Data::class)))
fun getListData(data: Deferred<List<Data>>): Deferred<List<Data>>`

@ProviderKey("key3", EntryClass(Map::class, EntryClass(Int::class), EntryClass(Data::class)))
fun getMapData(data: Deferred<Map<Int, Data>>): Deferred<Map<Int, Data>>

Please not that this PR also includes: https://github.com/epam/CoroutinesCache/pull/13

LikeAnyan commented 5 years ago

Pushed two commits over comments above, please write opinion about JsonMapper interface (I think that newParameterizedType could be removed from interface, but maybe there are cases when user needs it)