/*
* 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 mx.edu.um.mateo.colportor.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
/**
*
* @author osoto
*/
@Entity
@Table(name = "pedido_colportor_item")
public class PedidoColportorItem implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Version
private Integer version;
@NotBlank
@Column(nullable = false, length=50)
private String item; //libro, revista, etc.
@Column(nullable = false)
private Integer cantidad; //numero de determinado libro o revista
@Column(nullable = false, scale = 2, precision = 16)
private BigDecimal precioUnitario;
@Column(nullable = true, length = 250)
private String observaciones;
@Column(nullable = false, length = 2)
private String status;
@ManyToOne
private PedidoColportor pedido;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
public Integer getCantidad() {
return cantidad;
}
public void setCantidad(Integer cantidad) {
this.cantidad = cantidad;
}
public BigDecimal getPrecioUnitario() {
return precioUnitario;
}
public void setPrecioUnitario(BigDecimal precioUnitario) {
this.precioUnitario = precioUnitario;
}
public String getObservaciones() {
return observaciones;
}
public void setObservaciones(String observaciones) {
this.observaciones = observaciones;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public PedidoColportor getPedido() {
return pedido;
}
public void setPedido(PedidoColportor pedido) {
this.pedido = pedido;
}
@Override
public int hashCode() {
int hash = 5;
hash = 53 * hash + Objects.hashCode(this.id);
hash = 53 * hash + Objects.hashCode(this.version);
hash = 53 * hash + Objects.hashCode(this.item);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final PedidoColportorItem other = (PedidoColportorItem) obj;
if (!Objects.equals(this.id, other.id)) {
return false;
}
if (!Objects.equals(this.version, other.version)) {
return false;
}
if (!Objects.equals(this.item, other.item)) {
return false;
}
return true;
}
@Override
public String toString() {
return "PedidoColportorItem{" + "id=" + id + ", version=" + version + ", item=" + item + ", cantidad=" + cantidad
+ ", precioUnitario=" + precioUnitario + ", observaciones=" + observaciones + ", status=" + status
+ ", pedido=" + pedido.getId() + '}';
}
}