package com.eactive.eai.rms.common.acl.monitoringCode;

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;

import com.eactive.apim.portal.monitoringcode.entity.MonitoringCode;
import com.eactive.apim.portal.monitoringcode.entity.MonitoringCodeId;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.common.acl.monitoringCode.UI.MonitoringCodeUI;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MonitoringCodeMapper extends GenericMapper<MonitoringCodeUI, MonitoringCode> {

	@Override
	@Mapping(source = "id.codeGroup", target = "codeGroup")
	@Mapping(source = "id.codeGroup", target = "id")
	@Mapping(source = "id.code", target = "code")
	MonitoringCodeUI toVo(MonitoringCode entity);

	@Override
	@InheritInverseConfiguration
	@Mapping(source = "codeGroup", target = "id.codeGroup")
	@Mapping(source = "code", target = "id.code")
	MonitoringCode toEntity(MonitoringCodeUI vo);

	MonitoringCodeId toId(MonitoringCodeUI vo);

	@InheritInverseConfiguration
	@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
	void updateToEntity(MonitoringCodeUI monitoringCodeUI, @MappingTarget MonitoringCode monitoringCode);

}