package ai.decompile.analysis.model.entity;

import jakarta.persistence.*;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;

@Entity
@Table(name = "library")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Library {
  @Id
  @GeneratedValue(strategy = GenerationType.UUID)
  private UUID id;

  @Column(nullable = false)
  private String name;

  @Column(columnDefinition = "TEXT")
  private String description;

  @OneToMany(mappedBy = "library", cascade = CascadeType.ALL, orphanRemoval = true)
  @Builder.Default
  private List<LibraryAlias> aliases = new ArrayList<>();

  @OneToMany(mappedBy = "library", cascade = CascadeType.ALL, orphanRemoval = true)
  @Builder.Default
  private List<LibrarySymbol> symbols = new ArrayList<>();

  @CreationTimestamp
  @Column(name = "created_at", nullable = false, updatable = false)
  private Instant createdAt;
}
