Giter Site home page Giter Site logo

ktmapping's Introduction

ktmapping

ktmapping 是基于ksp实现的kotlin专用的类mapstruct的映射工具

特性

  • 从Map/ResultSet映射到实体类
  • 以Map/ResultSet/实体类中的属性更新实体类
  • Map/ResultSet映射到实体类时根据配置的命名风格自动映射Map/Result中的属性
  • 来源对象的多个字段映射到目标对象的一个字段
  • 来源对象的一个字段映射到目标对象的多个字段
  • 编译期类型安全
注意事项
  • 所有属性复制都是浅拷贝
  • 以Map/ResultSet作为数据来源时生成的代码不是类型安全的,但是会在运行时抛出更加友好的错误提示
  • 不支持类型转换

基本规则

默认映射规则:默认按照属性名映射,实体类属性需要getter和setter,以Map/ResultSet为数据源时会假设数据源包含目标对象需要的所有属性

映射函数格式要求

  • 参数个数为1,类型为Map/ResultSet/自定义实体类
  • 返回值为自定义实体类
  • 创建目标对象时选择的构造器的规则:有主构造器用主构造器,没有主构造器时取参数最少的构造器
  • 构造器可见性必须为public
更新函数格式要求
  • 参数个数为2,第一个参数类型为Map/ResultSet/自定义实体类,第二个参数为自定义实体类
  • 返回值为Unit
  • 目标对象有可变属性

ktmapping's People

Contributors

afezeria avatar

Stargazers

zhaoweilong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.