class Identifier {
private long id;
private String type;
private List<Status> statuses;
}
class Customer {
private Identifier identifier;
}
class CustomerProfile {
private Customer customer;
}
class CustomerIdentifierDO {
private long id;
}
class CustomeDO {
private CustomerIdentiferDO custID;
}
class CustomerProfileDO {
private String category;
private List<Status> custStatuses;
private CustomeDO customer;
}
@Mapper
public interface CustomerProfileMapper {
CustomerProfile toCustomerProfile(CustomerProfileDO profileDO) ;
Customer toCustomer(CustomerDO customerDO);
Identifier toIdentifier(CustomerIdentifierDO identifierDO);
}
在此之前一切正常。现在我想将custStatuses
, category
of CustomerProfileDO
class 映射到statuses
and type
of Identifier
class 。我不知道如何为映射方法提供CustomerProfileDO
对象toIdentifier
,以便我可以在其中包含映射本身。我试过以下
@Mappings({
@Mapping(target = "customer.identifier.type", source = "category")
})
CustomerProfile toCustomerProfile(CustomerProfileDO profileDO) ;
但是这个嵌套映射覆盖了下面方法的所有映射配置。那不应该发生。
toIdentifer(CustomerIdentifierDO identifierDO)
有什么办法可以做到这一点?