package com.emonster.taroaichat.domain;

import com.emonster.taroaichat.domain.enumeration.ArcanaType;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.io.Serializable;
import java.time.Instant;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.domain.Persistable;

/**
 * Tarot card definitions
 */
@Entity
@Table(name = "tarot_card")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@JsonIgnoreProperties(value = { "new" })
@SuppressWarnings("common-java:DuplicatedBlocks")
public class TarotCard extends AbstractAuditingEntity<Long> implements Serializable, Persistable<Long> {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @NotNull
    @Size(max = 100)
    @Column(name = "name", length = 100, nullable = false, unique = true)
    private String name;

    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "arcana_type", nullable = false)
    private ArcanaType arcanaType;

    @NotNull
    @Min(value = 0)
    @Max(value = 78)
    @Column(name = "card_number", nullable = false)
    private Integer cardNumber;

    @NotNull
    @Size(max = 500)
    @Column(name = "image_url", length = 500, nullable = false)
    private String imageUrl;

    @Lob
    @Column(name = "upright_meaning", nullable = false)
    private String uprightMeaning;

    @Lob
    @Column(name = "reversed_meaning", nullable = false)
    private String reversedMeaning;

    @Size(max = 500)
    @Column(name = "keywords", length = 500)
    private String keywords;

    // Inherited createdBy definition
    // Inherited createdDate definition
    // Inherited lastModifiedBy definition
    // Inherited lastModifiedDate definition
    @org.springframework.data.annotation.Transient
    @Transient
    private boolean isPersisted;

    // jhipster-needle-entity-add-field - JHipster will add fields here

    public Long getId() {
        return this.id;
    }

    public TarotCard id(Long id) {
        this.setId(id);
        return this;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public TarotCard name(String name) {
        this.setName(name);
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ArcanaType getArcanaType() {
        return this.arcanaType;
    }

    public TarotCard arcanaType(ArcanaType arcanaType) {
        this.setArcanaType(arcanaType);
        return this;
    }

    public void setArcanaType(ArcanaType arcanaType) {
        this.arcanaType = arcanaType;
    }

    public Integer getCardNumber() {
        return this.cardNumber;
    }

    public TarotCard cardNumber(Integer cardNumber) {
        this.setCardNumber(cardNumber);
        return this;
    }

    public void setCardNumber(Integer cardNumber) {
        this.cardNumber = cardNumber;
    }

    public String getImageUrl() {
        return this.imageUrl;
    }

    public TarotCard imageUrl(String imageUrl) {
        this.setImageUrl(imageUrl);
        return this;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getUprightMeaning() {
        return this.uprightMeaning;
    }

    public TarotCard uprightMeaning(String uprightMeaning) {
        this.setUprightMeaning(uprightMeaning);
        return this;
    }

    public void setUprightMeaning(String uprightMeaning) {
        this.uprightMeaning = uprightMeaning;
    }

    public String getReversedMeaning() {
        return this.reversedMeaning;
    }

    public TarotCard reversedMeaning(String reversedMeaning) {
        this.setReversedMeaning(reversedMeaning);
        return this;
    }

    public void setReversedMeaning(String reversedMeaning) {
        this.reversedMeaning = reversedMeaning;
    }

    public String getKeywords() {
        return this.keywords;
    }

    public TarotCard keywords(String keywords) {
        this.setKeywords(keywords);
        return this;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    // Inherited createdBy methods
    public TarotCard createdBy(String createdBy) {
        this.setCreatedBy(createdBy);
        return this;
    }

    // Inherited createdDate methods
    public TarotCard createdDate(Instant createdDate) {
        this.setCreatedDate(createdDate);
        return this;
    }

    // Inherited lastModifiedBy methods
    public TarotCard lastModifiedBy(String lastModifiedBy) {
        this.setLastModifiedBy(lastModifiedBy);
        return this;
    }

    // Inherited lastModifiedDate methods
    public TarotCard lastModifiedDate(Instant lastModifiedDate) {
        this.setLastModifiedDate(lastModifiedDate);
        return this;
    }

    @PostLoad
    @PostPersist
    public void updateEntityState() {
        this.setIsPersisted();
    }

    @org.springframework.data.annotation.Transient
    @Transient
    @Override
    public boolean isNew() {
        return !this.isPersisted;
    }

    public TarotCard setIsPersisted() {
        this.isPersisted = true;
        return this;
    }

    // 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 TarotCard)) {
            return false;
        }
        return getId() != null && getId().equals(((TarotCard) o).getId());
    }

    @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 "TarotCard{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            ", arcanaType='" + getArcanaType() + "'" +
            ", cardNumber=" + getCardNumber() +
            ", imageUrl='" + getImageUrl() + "'" +
            ", uprightMeaning='" + getUprightMeaning() + "'" +
            ", reversedMeaning='" + getReversedMeaning() + "'" +
            ", keywords='" + getKeywords() + "'" +
            ", createdBy='" + getCreatedBy() + "'" +
            ", createdDate='" + getCreatedDate() + "'" +
            ", lastModifiedBy='" + getLastModifiedBy() + "'" +
            ", lastModifiedDate='" + getLastModifiedDate() + "'" +
            "}";
    }
}
