2010-09-15 72 views
0

我使用推土机来映射bean属性。我这样做的方式是:dozerMapper.map(sourceClass,destClass)。这将返回整个映射类。 但是,有没有办法获得个人财产映射到? 例如,如果SourceClass具有propA,是否有一种简单的方法来获取propA映射到的DestClass中的相应属性?在推土机上按字段映射获取字段

+0

我想避免在我的代码中解析映射xml :) – missionE46 2010-09-15 15:40:01

回答

1

推土机并未公开其地图信息。你可能想看看ModelMapper它提供了一个SPI,可让您阅读的映射:

ModelMapper modelMapper = new ModelMapper(); 
List<Mapping> mappings = modelMapper.createTypeMap(Source.class, Dest.class).getMappings(); 

您可以在docs for the mapping interface阅读更多入住或退房手续在项目现场的一些常见的例子和文档:

http://modelmapper.org