/*
 * 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.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author attila
 */
@Entity
@Table(name = "email_address")
@SequenceGenerator(name="EMAIL_ADDRESS_SEQUENCE", sequenceName="EMAIL_ADDRESS_ID_SEQ")
public class EmailAddress implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="EMAIL_ADDRESS_SEQUENCE")
    private Long id;
    @Column(name = "email_address", nullable = false)
    private String emailAddress;
    @Column(name = "duplicated", nullable = false)
    private boolean duplicated;
    @Column(name = "wrong", nullable = false)
    private boolean wrong;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable=false)
    @ManyToOne
    private NmailUser userId;

    public EmailAddress() {
    }

    public EmailAddress(Long id) {
        this.id = id;
    }

    public EmailAddress(Long id, String emailAddress) {
        this.id = id;
        this.emailAddress = emailAddress;
    }

    public Long getId() {
        return id;
    }

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

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public NmailUser getUserId() {
        return userId;
    }

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

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.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 EmailAddress)) {
            return false;
        }
        EmailAddress other = (EmailAddress) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

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

    public boolean getDuplicated() {
        return duplicated;
    }

    public void setDuplicated(boolean duplicated) {
        this.duplicated = duplicated;
    }

    public boolean getWrong() {
        return wrong;
    }

    public void setWrong(boolean wrong) {
        this.wrong = wrong;
    }

}
