package com.eactive.eai.rms.onl.manage.comm.codeMan;

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.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.data.entity.onl.code.CodeGroup;

@Mapper(componentModel = "spring", uses = { CodeMapper.class }, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface CodeGroupMapper extends GenericMapper<CodeGroupUI, CodeGroup> {

	@Override
	@Mapping(source = "codegroup", target = "cdGroup")
	@Mapping(source = "description", target = "cdGroupDesc")
	@Mapping(expression = "java(entity.getCodes().size())", target = "childCnt")
	CodeGroupUI toVo(CodeGroup entity);

	@Override
	@InheritInverseConfiguration
	CodeGroup toEntity(CodeGroupUI vo);

	@InheritInverseConfiguration
	@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
	void updateToEntity(CodeGroupUI codeGroupUI, @MappingTarget CodeGroup codeGroup);

}
