RepositoryMapper
RepositoryMapper<In,Out>
encapuslates a Repository
instance of type In
and exposes a new interface of Repository
of type Out
, mapping the objects using a Mapper<In,Out>
and Mapper<Out,In>
.
Usage
- Kotlin
- Swift
fun provideDataRepositoryMapper(dataMapperHarmony: Mapper<@JvmSuppressWildcards DataEntity, @JvmSuppressWildcards DataModel>, dataEntityMapperHarmony: Mapper<@JvmSuppressWildcards DataModel, @JvmSuppressWildcards DataEntity> ): RepositoryMapper<DataEntity, DataModel> {
val dataStorageDataSource = DataStorageDataSource()
val singleDataSourceRepository = SingleDataSourceRepository( dataStorageDataSource, dataStorageDataSource, dataStorageDataSource)
return RepositoryMapper(singleDataSourceRepository, singleDataSourceRepository, singleDataSourceRepository, dataMapperHarmony, dataEntityMapperHarmony)
Operation Types
Any Operation
can be passed to a RepositoryMapper<In,Out>
.
Other Implementations
Together with RepositoryMapper<In,Out>
there are also similar implementations for:
GetRepositoryMapper<In,Out>
: ImplementsGetRepository
.PutRepositoryMapper<In,Out>
: ImplementsPutRepository
.
There is no need to map a DeleteRepository
.