/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cosmodas.EntCosmos;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author obper
 */
@Entity
@Table(name = "ruta_reparto")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "RutaReparto.findAll", query = "SELECT r FROM RutaReparto r"),
        @NamedQuery(name = "RutaReparto.findByRuta", query = "SELECT r FROM RutaReparto r WHERE r.ruta = :ruta"),
        @NamedQuery(name = "RutaReparto.findByDireccion", query = "SELECT r FROM RutaReparto r WHERE r.direccion = :direccion"),
        @NamedQuery(name = "RutaReparto.findByColor", query = "SELECT r FROM RutaReparto r WHERE r.color = :color"),
        @NamedQuery(name = "RutaReparto.findByTerritorio", query = "SELECT r FROM RutaReparto r WHERE r.territorio = :territorio"),
        @NamedQuery(name = "RutaReparto.findByCodigo", query = "SELECT r FROM RutaReparto r WHERE r.codigo = :codigo"),
        @NamedQuery(name = "RutaReparto.findByTerritorioAndTipo", query = "SELECT r FROM RutaReparto r WHERE r.territorio = :territorio AND r.tipo = :tipo")
})
public class RutaReparto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 6)
    @Column(name = "ruta")
    private String ruta;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "direccion")
    private String direccion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "color")
    private String color;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "codigo")
    private String codigo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "territorio")
    private String territorio;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "color_codigo")
    private String colorCodigo;
    @Column(name = "tipo")
    private Integer tipo;

    public RutaReparto() {
    }

    public RutaReparto(String codigo) {
        this.codigo = codigo;
    }

    public RutaReparto(String codigo, String ruta, String direccion, String color, Integer tipo) {
        this.codigo = codigo;
        this.ruta = ruta;
        this.direccion = direccion;
        this.color = color;
        this.tipo = tipo;
    }

    public String getRuta() {
        return ruta;
    }

    public void setRuta(String ruta) {
        this.ruta = ruta;
    }

    public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getTerritorio() {
        return territorio;
    }

    public void setTerritorio(String territorio) {
        this.territorio = territorio;
    }

    public String getColorCodigo() {
        return colorCodigo;
    }

    public void setColorCodigo(String colorCodigo) {
        this.colorCodigo = colorCodigo;
    }

    public Integer getTipo() {
        return tipo;
    }

    public void setTipo(Integer tipo) {
        this.tipo = tipo;
    }

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

    @Override
    public String toString() {
        return "com.cosmodas.dbcon.RutaReparto[ codigo=" + codigo + " ]";
    }

}
