class ReadableProductTypeMapper implements Mapper<ProductType, ReadableProductType> {

	@Override
	public ReadableProductType convert(ProductType source, MerchantStore store, Language language) {
		ReadableProductType type = new ReadableProductType();
		return this.merge(source, type, store, language);
	}

	@Override
	public ReadableProductType merge(ProductType source, ReadableProductType destination, MerchantStore store,
									 Language language) {<FILL_FUNCTION_BODY>}
	
	private ReadableProductType type (ProductType type, Language language) {
		ReadableProductType readableType = null;


		if(language != null) {
			readableType = new ReadableProductType();
			if(!CollectionUtils.isEmpty(type.getDescriptions())) {
				Optional<ProductTypeDescription> desc = type.getDescriptions().stream().filter(t -> t.getLanguage().getCode().equals(language.getCode()))
				.map(d -> typeDescription(d)).findFirst();
				if(desc.isPresent()) {
					readableType.setDescription(desc.get());
				}
			}
		} else {
			
			readableType = new ReadableProductTypeFull();
			List<ProductTypeDescription> descriptions = type.getDescriptions().stream().map(t -> this.typeDescription(t)).collect(Collectors.toList());
			((ReadableProductTypeFull)readableType).setDescriptions(descriptions);
			
		}
		
		readableType.setCode(type.getCode());
		readableType.setId(type.getId());
		readableType.setVisible(type.getVisible() != null && type.getVisible().booleanValue() ? true:false);
		readableType.setAllowAddToCart(type.getAllowAddToCart() != null && type.getAllowAddToCart().booleanValue() ? true:false);
		
		return readableType;
	}
	
	private ProductTypeDescription typeDescription(com.salesmanager.core.model.catalog.product.type.ProductTypeDescription description) {
		ProductTypeDescription desc = new ProductTypeDescription();
		desc.setId(description.getId());
		desc.setName(description.getName());
		desc.setDescription(description.getDescription());
		desc.setLanguage(description.getLanguage().getCode());
		return desc;
	}

}

		Validate.notNull(source, "ProductType cannot be null");
		Validate.notNull(destination, "ReadableProductType cannot be null");
		return type(source, language);
	
<no_super_class>