https://github.com/chrynan/mapper
A simple collection of interfaces for mapping objects.
https://github.com/chrynan/mapper
clean-architecture clean-code kotlin kotlin-library kotlin-multiplatform mapper
Last synced: 5 months ago
JSON representation
A simple collection of interfaces for mapping objects.
- Host: GitHub
- URL: https://github.com/chrynan/mapper
- Owner: chRyNaN
- License: apache-2.0
- Created: 2018-01-27T16:13:19.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-08-20T17:57:14.000Z (over 3 years ago)
- Last Synced: 2023-02-27T06:41:52.600Z (almost 3 years ago)
- Topics: clean-architecture, clean-code, kotlin, kotlin-library, kotlin-multiplatform, mapper
- Language: Kotlin
- Homepage:
- Size: 87.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mapper
A simple collection of interfaces for mapping between objects.

## 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
```kotlin
class MyMapper : Mapper {
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
```kotlin
class MyMapper : BiDirectionalMapper {
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](https://repsy.io). Refer to
the [releases page](https://github.com/chRyNaN/mapper/releases) for the latest version.

### Repository
```kotlin
repositories {
maven { url = "https://repo.repsy.io/mvn/chrynan/public" }
}
```
### Dependencies
```kotlin
implementation("com.chrynan.mapper:mapper-core:$VERSION")
```
## Documentation
Refer to the [docs](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.
```