package ru.nbch.indicsearchservice.model;

import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Objects;

public class LocalizationObject {
    private Long id;

    private Long version;
    @Nullable
    private String code;
    @Nullable
    private LocalDateTime dateCreated;
    @Nullable
    private LocalDateTime lastUpdated;
    @Nullable
    private String text;

    @NotNull
    private String loc = "*";

    @NotNull
    private Short relevance = (short) 1;

    public LocalizationObject() {
    }

    public LocalizationObject(Long id, Long version, @Nullable String code, @Nullable LocalDateTime dateCreated, @Nullable LocalDateTime lastUpdated, @Nullable String text, String loc, Short relevance) {
        this.id = id;
        this.version = version;
        this.code = code;
        this.dateCreated = dateCreated;
        this.lastUpdated = lastUpdated;
        this.text = text;
        this.loc = loc;
        this.relevance = relevance;
    }

    public Long getId() {
        return id;
    }

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

    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    @Nullable
    public String getCode() {
        return code;
    }

    public void setCode(@Nullable String code) {
        this.code = code;
    }

    @Nullable
    public LocalDateTime getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(@Nullable LocalDateTime dateCreated) {
        this.dateCreated = dateCreated;
    }

    @Nullable
    public LocalDateTime getLastUpdated() {
        return lastUpdated;
    }

    public void setLastUpdated(@Nullable LocalDateTime lastUpdated) {
        this.lastUpdated = lastUpdated;
    }

    @Nullable
    public String getText() {
        return text;
    }

    public void setText(@Nullable String text) {
        this.text = text;
    }

    public String getLoc() {
        return loc;
    }

    public void setLoc(String loc) {
        this.loc = loc;
    }

    public Short getRelevance() {
        return relevance;
    }

    public void setRelevance(Short relevance) {
        this.relevance = relevance;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        LocalizationObject that = (LocalizationObject) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "LocalizationObject{" +
            "id=" + id +
            ", version=" + version +
            ", code='" + code + '\'' +
            ", dateCreated=" + dateCreated +
            ", lastUpdated=" + lastUpdated +
            ", text='" + text + '\'' +
            ", loc='" + loc + '\'' +
            ", relevance=" + relevance +
            '}';
    }
}
