content: package com.adyen.demo.store.domain;
  
  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  import java.io.Serializable;
  import java.util.HashSet;
  import java.util.Set;
  import javax.persistence.*;
  import javax.validation.constraints.*;
  import org.hibernate.annotations.Cache;
  import org.hibernate.annotations.CacheConcurrencyStrategy;
  
  /**
   * A ProductCategory.
   */
  @Entity
  @Table(name = "product_category")
  @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
  public class ProductCategory implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @NotNull
      @Column(name = "name", nullable = false)
      private String name;
  
      @Column(name = "description")
      private String description;
  
      @OneToMany(mappedBy = "productCategory")
      @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
      @JsonIgnoreProperties(value = { "productCategory" }, allowSetters = true)
      private Set<Product> products = new HashSet<>();
  
      // jhipster-needle-entity-add-field - JHipster will add fields here
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public ProductCategory id(Long id) {
          this.id = id;
          return this;
      }
  
      public String getName() {
          return this.name;
      }
  
      public ProductCategory name(String name) {
          this.name = name;
          return this;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getDescription() {
          return this.description;
      }
  
      public ProductCategory description(String description) {
          this.description = description;
          return this;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public Set<Product> getProducts() {
          return this.products;
      }
  
      public ProductCategory products(Set<Product> products) {
          this.setProducts(products);
          return this;
      }
  
      public ProductCategory addProduct(Product product) {
          this.products.add(product);
          product.setProductCategory(this);
          return this;
      }
  
      public ProductCategory removeProduct(Product product) {
          this.products.remove(product);
          product.setProductCategory(null);
          return this;
      }
  
      public void setProducts(Set<Product> products) {
          if (this.products != null) {
              this.products.forEach(i -> i.setProductCategory(null));
          }
          if (products != null) {
              products.forEach(i -> i.setProductCategory(this));
          }
          this.products = products;
      }
  
      // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here
  
      @Override
      public boolean equals(Object o) {
          if (this == o) {
              return true;
          }
          if (!(o instanceof ProductCategory)) {
              return false;
          }
          return id != null && id.equals(((ProductCategory) o).id);
      }
  
      @Override
      public int hashCode() {
          // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
          return getClass().hashCode();
      }
  
      // prettier-ignore
      @Override
      public String toString() {
          return "ProductCategory{" +
              "id=" + getId() +
              ", name='" + getName() + "'" +
              ", description='" + getDescription() + "'" +
              "}";
      }
  }
  