/*
 * 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 = "user_restriction")
@NamedQueries({})
public class UserRestriction implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "able_to_set_sender", nullable = false)
    private boolean ableToSetSender;
    @Column(name = "can_import", nullable = false)
    private boolean canImport;
    @Id
    @Column(name = "user_id", nullable = false)
    private Long userId;
    @Column(name = "can_set_pop3")
    private Boolean canSetPop3;
    //@JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false, nullable=false)
    //@OneToOne
    //private NmailUser nmailUser;

    public UserRestriction() {
    }

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

    public UserRestriction(Long userId, boolean ableToSetSender, boolean canImport) {
        this.userId = userId;
        this.ableToSetSender = ableToSetSender;
        this.canImport = canImport;
    }

    public boolean getAbleToSetSender() {
        return ableToSetSender;
    }

    public void setAbleToSetSender(boolean ableToSetSender) {
        this.ableToSetSender = ableToSetSender;
    }

    public boolean getCanImport() {
        return canImport;
    }

    public void setCanImport(boolean canImport) {
        this.canImport = canImport;
    }

    public Long getUserId() {
        return userId;
    }

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

    public Boolean getCanSetPop3() {
        return canSetPop3;
    }

    public void setCanSetPop3(Boolean canSetPop3) {
        this.canSetPop3 = canSetPop3;
    }

    /*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 UserRestriction)) {
            return false;
        }
        UserRestriction other = (UserRestriction) 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.UserRestriction[userId=" + userId + "]";
    }

}
