Skip to content
/ mapper Public

A simple collection of interfaces for mapping objects.

License

Notifications You must be signed in to change notification settings

chRyNaN/mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

178da67 · Aug 20, 2022

History

36 Commits
Mar 19, 2021
Aug 20, 2022
Mar 19, 2021
Aug 3, 2021
Mar 5, 2022
Mar 5, 2022
Jan 27, 2018
Mar 19, 2021
Aug 20, 2022
Mar 19, 2021
Jan 27, 2018
Jan 27, 2018
Mar 5, 2022

Repository files navigation

mapper

A simple collection of interfaces for mapping between objects.
GitHub tag (latest by date)

Using the library

This library contains two simple mapping interfaces: UniDirectionalMapper and BiDirectionalMapper. There is also a typealias called Mapper for the UniDirectionalMapper interface.

Unidirectional Mapping

class MyMapper : Mapper<Model, ViewModel> {

    override fun map(value: Model): ViewModel = ...
}

...

// Using the Mapper
val viewModel = mapper.map(value = myModel)

// Or in a Flow
getFlowOfModels()
    .map(mapper::map)

BiDirectional Mapping

class MyMapper : BiDirectionalMapper<InModel, OutModel> {

    override fun mapIn(value: InModel): OutModel = ...

    override fun mapOut(value: OutModel): InModel = ...
}

// Using the Mapper
val mapOut = mapper.mapIn(value = mapIn)
val mapInAgain = mapper.mapOut(value = mapOut)

// Or in a Flow
getFlowOfModels()
    .map(mapper::mapIn)

Building

The library is provided through Repsy. Refer to the releases page for the latest version.
GitHub tag (latest by date)

Repository

repositories {
    maven { url = "https://repo.repsy.io/mvn/chrynan/public" }
}

Dependencies

implementation("com.chrynan.mapper:mapper-core:$VERSION")

Documentation

Refer to the docs folder for documentation and more information about the library.

License

Copyright 2020 chRyNaN

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.