package es.uv.garcosda.data.domain;

import java.io.Serializable;
import java.util.Date;

import org.hibernate.annotations.GenericGenerator;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;

@Entity
@Table(name = "mails")
public class Mail implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(generator = "UUID")
	@GenericGenerator(
            name = "UUID",
            strategy = "org.hibernate.id.UUIDGenerator"
    )
	@Column(name="id", columnDefinition = "VARCHAR(255)", updatable = false, nullable = false)
	private String id;
	@Column(name="_from")
	private String from;
	@Column(name="_to")
	private String to;
	@Lob
	private String subject;
	@Lob
	private String body;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "_date")
	private Date date;
	
	public Mail() {}
	
	public Mail(String from, String to, String subject, String body, Date date) {
		this.from = from;
		this.to = to;
		this.subject = subject;
		this.body = body;
		this.date = date;
	}
	
	public String getId() {
		return id;
	}

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

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}
	
	public Date getDate() {
		return this.date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
	@Override
	public String toString() {
		return String.format("Email{from=%s, to=%s, subject=%s}", this.getFrom(), this.getTo(), this.getSubject());
	}
	
}
