class PersistableProductOptionSetMapper implements Mapper<PersistableProductOptionSet, ProductOptionSet> {

	@Autowired
	private ProductOptionService productOptionService;
	
	@Autowired
	private ProductOptionValueService productOptionValueService;
	
	@Autowired
	private ProductTypeService productTypeService;

	@Override
	public ProductOptionSet convert(PersistableProductOptionSet source, MerchantStore store, Language language) {
		
		
		ProductOptionSet optionSet = new ProductOptionSet();
		return this.merge(source, optionSet, store, language);

	}

	private ProductOptionValue value(Long productOptionValue, MerchantStore store) {
		return productOptionValueService.getById(store, productOptionValue);
	}
	
	@Override
	public ProductOptionSet merge(PersistableProductOptionSet source, ProductOptionSet destination,
								  MerchantStore store, Language language) {<FILL_FUNCTION_BODY>}

}

		Validate.notNull(destination, "ProductOptionSet must not be null");
		
		destination.setId(source.getId());
		destination.setCode(source.getCode());
		destination.setOptionDisplayOnly(source.isReadOnly());
		
		ProductOption option = productOptionService.getById(store, source.getOption());
		destination.setOption(option);
		
		if(!CollectionUtils.isEmpty(source.getOptionValues())) {
			List<ProductOptionValue> values = source.getOptionValues().stream().map(id -> value(id, store)).collect(Collectors.toList());
			destination.setValues(values);
		}
		
		if(!CollectionUtils.isEmpty(source.getProductTypes())) {
			try {
				List<ProductType> types = productTypeService.listProductTypes(source.getProductTypes(), store, language);
				Set<ProductType> typesSet = new HashSet<ProductType>(types);
				destination.setProductTypes(typesSet);
			} catch (ServiceException e) {
				throw new ConversionRuntimeException("Error while mpping ProductOptionSet", e);
			}
		}
		
		return destination;
	
<no_super_class>