项目作者: ResulSilay

项目描述 :
Allows you to map two classes for you. It uses the Gson library in doing this. Contains functions created using Gson.
高级语言: Kotlin
项目地址: git://github.com/ResulSilay/AutoMapper.git
创建时间: 2020-09-19T14:33:48Z
项目社区:https://github.com/ResulSilay/AutoMapper

开源协议:

下载


AutoMapper

Allows you to map two classes for you. It uses the Gson library in doing this. Contains functions created using Gson.

Installation

Add it in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Add the dependency

  1. implementation 'com.github.ResulSilay:AutoMapper:1.0.0'

Usage

  1. data class UserModel(
  2. val id: Int,
  3. val name: String,
  4. val password: String,
  5. val address: String,
  6. val phone: String
  7. )
  8. data class UserRequest(
  9. val id: Int,
  10. val name: String,
  11. val address: String
  12. )
  1. val userModel = UserModel(
  2. id = 1,
  3. name = "Yunus Emre",
  4. password = "123",
  5. address = "Turkey",
  6. phone = "05350000000"
  7. )
  8. val userDTO = AutoMapper.map<UserRequest>(userModel)
  1. val userDTO = AutoMapper.map<List<UserRequest>>(userModelList)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT