package br.ufrj.g2matricula.domain;

import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;

import br.ufrj.g2matricula.domain.enumeration.MatriculaStatus;

/**
 * A Matricula.
 */
@Entity
@Table(name = "matricula")
@Document(indexName = "matricula")
public class Matricula implements Serializable {

    private static final long serialVersionUID = 1L;

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

    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false)
    private MatriculaStatus status;

    @ManyToOne
    private Aluno dreAluno;

    @ManyToOne
    private Curso curso;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

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

    public MatriculaStatus getStatus() {
        return status;
    }

    public Matricula status(MatriculaStatus status) {
        this.status = status;
        return this;
    }

    public void setStatus(MatriculaStatus status) {
        this.status = status;
    }

    public Aluno getDreAluno() {
        return dreAluno;
    }

    public Matricula dreAluno(Aluno aluno) {
        this.dreAluno = aluno;
        return this;
    }

    public void setDreAluno(Aluno aluno) {
        this.dreAluno = aluno;
    }

    public Curso getCurso() {
        return curso;
    }

    public Matricula curso(Curso curso) {
        this.curso = curso;
        return this;
    }

    public void setCurso(Curso curso) {
        this.curso = curso;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Matricula matricula = (Matricula) o;
        if (matricula.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), matricula.getId());
    }

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

    @Override
    public String toString() {
        return "Matricula{" +
            "id=" + getId() +
            ", status='" + getStatus() + "'" +
            "}";
    }
}
