package com.eactive.eai.rms.onl.manage.adapter.adapter.mapper;

import java.util.Map;
import java.util.stream.Collectors;

import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import com.eactive.eai.data.entity.onl.adapter.AdapterProp;
import com.eactive.eai.data.entity.onl.adapter.AdapterPropGroup;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.manage.adapter.adapter.ui.AdapterPropUI;

@Mapper(config = BaseMapperConfig.class, uses = {})
public interface AdapterPropUIMapper extends GenericMapper<AdapterPropUI, AdapterProp> {

	@Mapping(source = "id.prptygroupname", target = "prptygroupname")
	@Mapping(source = "id.prptyname", target = "prptyname")
	@Override
	AdapterPropUI toVo(AdapterProp entity);

	@InheritInverseConfiguration
	@Override
	AdapterProp toEntity(AdapterPropUI vo);

	default Map<String, AdapterPropUI> toMap(AdapterPropGroup adapterPropGroup) {
		return adapterPropGroup.getAdapterProps().stream()
				.collect(Collectors.toMap(adapterProp -> adapterProp.getId().getPrptygroupname(), this::toVo));
	}

}
