使用Orika从多个来源映射到目标

时间:2019-04-23 09:41:02

标签: java spring-boot orika

在Orika中有可能吗?这两个类都有2个源对象和目标作为实例属性。

示例:

public class Destination {
private String loginId;
private Integer contactId;}

public class LoginDetails {
    private String loginId;
    private String clientId;
}

public class AlertEntityIdentity {
  private Integer contactId;
}

1 个答案:

答案 0 :(得分:0)

mapperFactory.classMap(LoginDetails.class, Destination.class)
.byDefault().register();
mapperFactory.classMap(AlertEntityIdentity.class, Destination.class)
.byDefault().register();

假设您有loginDetailsalertEntityIdentity

Destination destination = mapperFacade.map(loginDetails, Destination.class);
mapperFacade.map(alertEntityIdentity, destination);// this will update contactId in destination