/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hu.nir.nmail.ejb.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author attila
 */
@Entity
@Table(name = "mail_folder")
@NamedQueries({})
public class MailFolder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "pop3_host", nullable = false)
    private String pop3Host;
    @Column(name = "pop3_password", nullable = false)
    private String pop3Password;
    @Column(name = "pop3_user_name", nullable = false)
    private String pop3UserName;
    @Column(name = "port", nullable = false)
    private int port;
    @Column(name = "ssl", nullable = false)
    private boolean ssl;
    @Id
    @Column(name = "user_id", nullable = false)
    private Long userId;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false, nullable= false)
    @OneToOne
    private NmailUser nmailUser;

    public MailFolder() {
    }

    public MailFolder(Long userId) {
        this.userId = userId;
    }

    public MailFolder(Long userId, String pop3Host, String pop3Password, String pop3UserName, int port, boolean ssl) {
        this.userId = userId;
        this.pop3Host = pop3Host;
        this.pop3Password = pop3Password;
        this.pop3UserName = pop3UserName;
        this.port = port;
        this.ssl = ssl;
    }

    public String getPop3Host() {
        return pop3Host;
    }

    public void setPop3Host(String pop3Host) {
        this.pop3Host = pop3Host;
    }

    public String getPop3Password() {
        return pop3Password;
    }

    public void setPop3Password(String pop3Password) {
        this.pop3Password = pop3Password;
    }

    public String getPop3UserName() {
        return pop3UserName;
    }

    public void setPop3UserName(String pop3UserName) {
        this.pop3UserName = pop3UserName;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public boolean getSsl() {
        return ssl;
    }

    public void setSsl(boolean ssl) {
        this.ssl = ssl;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public NmailUser getNmailUser() {
        return nmailUser;
    }

    public void setNmailUser(NmailUser nmailUser) {
        this.nmailUser = nmailUser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MailFolder)) {
            return false;
        }
        MailFolder other = (MailFolder) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "hu.nir.nmail.ejb.entity.MailFolder[userId=" + userId + "]";
    }

}
