content: package com.alphnology.data;
  
  import jakarta.persistence.*;
  import jakarta.validation.constraints.NotNull;
  import jakarta.validation.constraints.Size;
  import lombok.Getter;
  import lombok.Setter;
  import lombok.ToString;
  import org.hibernate.proxy.HibernateProxy;
  
  import java.io.Serializable;
  import java.util.Objects;
  
  @Getter
  @Setter
  @Entity
  @ToString
  @Table(
          name = "tags",
          indexes = {
                  @Index(columnList = "name")
          },
          uniqueConstraints = {
                  @UniqueConstraint(columnNames = {"name"})
          }
  )
  public class Tag implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long code;
  
      @NotNull
      @Size(min = 1, max = 100)
      @Column(unique = true)
      private String name;
  
      @Size(max = 20)
      private String color;
  
  
      @Override
      public final boolean equals(Object o) {
          if (this == o) return true;
          if (o == null) return false;
          Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
          Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
          if (thisEffectiveClass != oEffectiveClass) return false;
          Tag that = (Tag) o;
          return Objects.equals(getCode(), that.getCode());
      }
  
      @Override
      public final int hashCode() {
          return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
      }
  
  
  }
  