content: package com.aengdulab.trenditem.domain;
  
  import jakarta.persistence.Entity;
  import jakarta.persistence.FetchType;
  import jakarta.persistence.GeneratedValue;
  import jakarta.persistence.GenerationType;
  import jakarta.persistence.Id;
  import jakarta.persistence.ManyToOne;
  import jakarta.persistence.Table;
  import lombok.AccessLevel;
  import lombok.Getter;
  import lombok.NoArgsConstructor;
  
  @Entity
  @Table(name = "item_like")
  @Getter
  @NoArgsConstructor(access = AccessLevel.PROTECTED)
  public class Like {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @ManyToOne(fetch = FetchType.LAZY)
      private Item item;
  
      private Long userId;
  
      public Like(Item item, Long userId) {
          this(null, item, userId);
      }
  
      public Like(Long id, Item item, Long userId) {
          validateItem(item);
          validateUserId(userId);
          this.id = id;
          this.item = item;
          this.userId = userId;
      }
  
      private void validateItem(Item item) {
          if (item == null) {
              throw new IllegalArgumentException("Item cannot be null");
          }
      }
  
      private void validateUserId(Long userId) {
          if (userId == null) {
              throw new IllegalArgumentException("UserId cannot be null");
          }
      }
  }
  