/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rjconsultores.ventaboletos.entidad;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.SequenceGenerator;

/**
 *
 * @author Administrador
 */
@Entity
@SequenceGenerator(name = "RESTRICCION_SEQ", sequenceName = "RESTRICCION_SEQ", allocationSize=1)
@Table(name = "RESTRICCION")
public class RestriccionPago implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "RESTRICCION_SEQ")
    @Column(name = "RESTRICCION_ID")
    private Short restriccionId;
    @Column(name = "DESCRESTRICCION")
    private String descrestriccion;
    @Column(name = "ACTIVO")
    private Boolean activo;
    @Basic(optional = false)
    @Column(name = "FECMODIF")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecmodif;
    @Column(name = "USUARIO_ID")
    private Integer usuarioId;
    @OneToMany(mappedBy = "restriccion")
    private List<ConfigRestriccionPago> configRestriccionPagoList;

    public RestriccionPago() {
    }

    public Short getRestriccionId() {
        return restriccionId;
    }

    public void setRestriccionId(Short restriccionId) {
        this.restriccionId = restriccionId;
    }

    public String getDescrestriccion() {
        return descrestriccion;
    }

    public void setDescrestriccion(String descrestriccion) {
        this.descrestriccion = descrestriccion;
    }

    public Boolean getActivo() {
        return activo;
    }

    public void setActivo(Boolean activo) {
        this.activo = activo;
    }

    public Date getFecmodif() {
        return fecmodif;
    }

    public void setFecmodif(Date fecmodif) {
        this.fecmodif = fecmodif;
    }

    public Integer getUsuarioId() {
        return usuarioId;
    }

    public void setUsuarioId(Integer usuarioId) {
        this.usuarioId = usuarioId;
    }

    public List<ConfigRestriccionPago> getConfigRestriccionPagoList() {
        List<ConfigRestriccionPago> tmp = new ArrayList<ConfigRestriccionPago>();
        if (configRestriccionPagoList != null) {
            for (ConfigRestriccionPago crp : this.configRestriccionPagoList) {
                if (crp.getActivo()) {
                    tmp.add(crp);
                }
            }
        }

        return tmp;
    }

    public void setConfigRestriccionPagoList(List<ConfigRestriccionPago> configRestriccionPagoList) {
        this.configRestriccionPagoList = configRestriccionPagoList;
    }

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

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof RestriccionPago)) {
            return false;
        }
        RestriccionPago other = (RestriccionPago) object;
        if ((this.restriccionId == null && other.restriccionId != null) || (this.restriccionId != null && !this.restriccionId.equals(other.restriccionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getDescrestriccion();
    }
}
