我正在尝试使用java将DO转换为DTO,并在开始编写自己的工具之前寻找自动化工具。我只是想知道是否有同样的免费工具可用。
当前回答
还有一个Java映射引擎/框架Nomin: http://nomin.sourceforge.net。
其他回答
还有一个Java映射引擎/框架Nomin: http://nomin.sourceforge.net。
我很高兴添加Moo作为一个选项,尽管很明显我对它有偏见: http://geoffreywiseman.github.com/Moo/
它在简单的情况下很容易使用,在更复杂的情况下也很有能力,尽管我仍然可以想象在一些方面对它进行进一步的改进,以解决更复杂的问题。
另一个是Orika - https://github.com/orika-mapper/orika
Orika is a Java Bean mapping framework that recursively copies (among other capabilities) data from one object to another. It can be very useful when developing multi-layered applications. Orika focuses on automating as much as possible, while providing customization through configuration and extension where needed. Orika enables the developer to : Map complex and deeply structured objects "Flatten" or "Expand" objects by mapping nested properties to top-level properties, and vice versa Create mappers on-the-fly, and apply customizations to control some or all of the mapping Create converters for complete control over the mapping of a specific set of objects anywhere in the object graph--by type, or even by specific property name Handle proxies or enhanced objects (like those of Hibernate, or the various mock frameworks) Apply bi-directional mapping with one configuration Map to instances of an appropriate concrete class for a target abstract class or interface Handle reverse mappings Handle complex conventions beyond JavaBean specs. Orika uses byte code generation to create fast mappers with minimal overhead.
附近有一些图书馆:
Commons-BeanUtils: ConvertUtils -> Utility methods for converting String scalar values to objects of the specified Class, String arrays to arrays of the specified Class. Commons-Lang: ArrayUtils -> Operations on arrays, primitive arrays (like int[]) and primitive wrapper arrays (like Integer[]). Spring framework: Spring has an excellent support for PropertyEditors, that can also be used to transform Objects to/from Strings. Dozer: Dozer is a powerful, yet simple Java Bean to Java Bean mapper that recursively copies data from one object to another. Typically, these Java Beans will be of different complex types. ModelMapper: ModelMapper is an intelligent object mapping framework that automatically maps objects to each other. It uses a convention based approach to map objects while providing a simple refactoring safe API for handling specific use cases. MapStruct: MapStruct is a compile-time code generator for bean mappings, resulting in fast (no usage of reflection or similar), dependency-less and type-safe mapping code at runtime. Orika: Orika uses byte code generation to create fast mappers with minimal overhead. Selma: Compile-time code-generator for mappings JMapper: Bean mapper generation using Annotation, XML or API (seems dead, last updated 2 years ago) Smooks: The Smooks JavaBean Cartridge allows you to create and populate Java objects from your message data (i.e. bind data to) (suggested by superfilin in comments). (No longer under active development) Commons-Convert: Commons-Convert aims to provide a single library dedicated to the task of converting an object of one type to another. The first stage will focus on Object to String and String to Object conversions. (seems dead, last update 2010) Transmorph: Transmorph is a free java library used to convert a Java object of one type into an object of another type (with another signature, possibly parameterized). (seems dead, last update 2013) EZMorph: EZMorph is simple java library for transforming an Object to another Object. It supports transformations for primitives and Objects, for multidimensional arrays and transformations with DynaBeans (seems dead, last updated 2008) Morph: Morph is a Java framework that eases the internal interoperability of an application. As information flows through an application, it undergoes multiple transformations. Morph provides a standard way to implement these transformations. (seems dead, last update 2008) Lorentz: Lorentz is a generic object-to-object conversion framework. It provides a simple API to convert a Java objects of one type into an object of another type. (seems dead) OTOM: With OTOM, you can copy any data from any object to any other object. The possibilities are endless. Welcome to "Autumn". (seems dead)
使用Apache commons beanutils:
静态无效copyProperties(对象dest,对象origin) -将所有属性值从源bean复制到目标bean 属性名为的情况 相同。
http://commons.apache.org/proper/commons-beanutils/
推荐文章
- javac和Eclipse编译器之间的区别是什么?
- 工厂模式和策略模式之间的区别是什么?
- 在Java中使用正则表达式提取值
- 如何允许所有网络连接类型HTTP和HTTPS在Android(9)馅饼?
- Intellij IDEA Java类在保存时不能自动编译
- 何时使用Mockito.verify()?
- 在maven中安装mvn到底做什么
- 不可变与不可修改的集合
- 如何在JSON中使用杰克逊更改字段名
- GSON -日期格式
- 如何从线程捕获异常
- 无法解析主机"<URL here>"没有与主机名关联的地址
- 如何在Java中打印二叉树图?
- String.format()在Java中格式化双重格式
- com.jcraft.jsch.JSchException: UnknownHostKey