2011-06-23 66 views

回答

6

您可能會收到ModelMapper。即使名稱不完全相同,它也會智能地映射屬性(字段/方法)。定義映射特定的屬性或跳過簡單,使用真正的代碼,而不是XML的:

ModelMapper modelMapper = new ModelMapper(); 
modelMapper.addMappings(new PropertyMap<Order, OrderDTO>() { 
    protected void configure() { 
    map().setBillingStreet(source.getBillingStreetAddress()); 
    skip().setBillingCity(null); 
    } 
}); 

退房的項目主頁瞭解更多信息:

http://modelmapper.org

3

我們認爲mapstruct我們的用例。請參見下面的示例:

@Mapper 
public interface MyMapper { 

    MyMapper INSTANCE = Mappers.getMapper(MyMapper.class); 

    To to(From from); 

} 

這裏是MapStruct針對塞爾瑪Orika,ModelMapper,推土機和手動映射的性能比較:

Manual mapping vs. Selma vs. MapStruct vs. Orika vs. ModelMapper vs. Dozer

Selma vs. MapStruct

相關問題