content: package com.adyen.demo.store.service;
  
  import com.adyen.demo.store.domain.ProductCategory;
  import com.adyen.demo.store.repository.ProductCategoryRepository;
  import java.util.Optional;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.data.domain.Page;
  import org.springframework.data.domain.Pageable;
  import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  
  /**
   * Service Implementation for managing {@link ProductCategory}.
   */
  @Service
  @Transactional
  public class ProductCategoryService {
  
      private final Logger log = LoggerFactory.getLogger(ProductCategoryService.class);
  
      private final ProductCategoryRepository productCategoryRepository;
  
      public ProductCategoryService(ProductCategoryRepository productCategoryRepository) {
          this.productCategoryRepository = productCategoryRepository;
      }
  
      /**
       * Save a productCategory.
       *
       * @param productCategory the entity to save.
       * @return the persisted entity.
       */
      public ProductCategory save(ProductCategory productCategory) {
          log.debug("Request to save ProductCategory : {}", productCategory);
          return productCategoryRepository.save(productCategory);
      }
  
      /**
       * Partially update a productCategory.
       *
       * @param productCategory the entity to update partially.
       * @return the persisted entity.
       */
      public Optional<ProductCategory> partialUpdate(ProductCategory productCategory) {
          log.debug("Request to partially update ProductCategory : {}", productCategory);
  
          return productCategoryRepository
              .findById(productCategory.getId())
              .map(
                  existingProductCategory -> {
                      if (productCategory.getName() != null) {
                          existingProductCategory.setName(productCategory.getName());
                      }
                      if (productCategory.getDescription() != null) {
                          existingProductCategory.setDescription(productCategory.getDescription());
                      }
  
                      return existingProductCategory;
                  }
              )
              .map(productCategoryRepository::save);
      }
  
      /**
       * Get all the productCategories.
       *
       * @param pageable the pagination information.
       * @return the list of entities.
       */
      @Transactional(readOnly = true)
      public Page<ProductCategory> findAll(Pageable pageable) {
          log.debug("Request to get all ProductCategories");
          return productCategoryRepository.findAll(pageable);
      }
  
      /**
       * Get one productCategory by id.
       *
       * @param id the id of the entity.
       * @return the entity.
       */
      @Transactional(readOnly = true)
      public Optional<ProductCategory> findOne(Long id) {
          log.debug("Request to get ProductCategory : {}", id);
          return productCategoryRepository.findById(id);
      }
  
      /**
       * Delete the productCategory by id.
       *
       * @param id the id of the entity.
       */
      public void delete(Long id) {
          log.debug("Request to delete ProductCategory : {}", id);
          productCategoryRepository.deleteById(id);
      }
  }
  