package com.eactive.eai.rms.onl.apim.approval.prodclient;

import com.eactive.apim.portal.app.entity.ProdClient;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.transaction.apim.mapping.ApiSpecUIMapper;
import org.mapstruct.BeanMapping;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;

@Mapper(config = BaseMapperConfig.class, componentModel = "spring", uses = {ApiSpecUIMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class ProdClientUIMapper implements GenericMapper<ProdClientUI, ProdClient> {

    @InheritInverseConfiguration
    @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
    @Mapping(target = "apiList", expression = "java(apiSpecUIMapper.mapList(prodClientUI.getApiList()))")
    public abstract void updateToEntity(ProdClientUI prodClientUI, @MappingTarget ProdClient prodClient);
}
