package com.mycompany.model; import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.validation.constraints.DecimalMin; import javax.validation.constraints.NotNull; import org.hibernate.validator.constraints.NotEmpty; @Entity @Table(name = "movimiento") public class Movimiento implements Serializable{ /** * */ private static final long serialVersionUID = 1L; private Long id; private Persona persona; private String descripcion; private BigDecimal valor; private TipoMovimiento tipo; private Date fechaVencimiento; private Date fechaPago; @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } @NotNull @ManyToOne(optional = false) @JoinColumn(name = "persona_id") public Persona getPersona() { return persona; } public void setPersona(Persona persona) { this.persona = persona; } @NotEmpty @Column(length = 80, nullable = false) public String getDescripcion() { return descripcion; } public void setDescripcion(String descripcion) { this.descripcion = descripcion; } @DecimalPositivo @Column(precision = 10, scale = 2, nullable = false) public BigDecimal getValor() { return valor; } public void setValor(BigDecimal valor) { this.valor = valor; } @NotNull @Enumerated(EnumType.STRING) @Column(nullable = false) public TipoMovimiento getTipo() { return tipo; } public void setTipo(TipoMovimiento tipo) { this.tipo = tipo; } @NotNull @Temporal(TemporalType.DATE) @Column(name = "fecha_vencimiento", nullable = false) public Date getFechaVencimiento() { return fechaVencimiento; } public void setFechaVencimiento(Date fechaVencimiento) { this.fechaVencimiento = fechaVencimiento; } @Temporal(TemporalType.DATE) @Column(name = "fecha_pago", nullable = true) public Date getFechaPago() { return fechaPago; } public void setFechaPago(Date fechaPago) { this.fechaPago = fechaPago; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((descripcion == null) ? 0 : descripcion.hashCode()); result = prime * result + ((fechaPago == null) ? 0 : fechaPago.hashCode()); result = prime * result + ((fechaVencimiento == null) ? 0 : fechaVencimiento.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((persona == null) ? 0 : persona.hashCode()); result = prime * result + ((tipo == null) ? 0 : tipo.hashCode()); result = prime * result + ((valor == null) ? 0 : valor.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Movimiento other = (Movimiento) obj; if (descripcion == null) { if (other.descripcion != null) return false; } else if (!descripcion.equals(other.descripcion)) return false; if (fechaPago == null) { if (other.fechaPago != null) return false; } else if (!fechaPago.equals(other.fechaPago)) return false; if (fechaVencimiento == null) { if (other.fechaVencimiento != null) return false; } else if (!fechaVencimiento.equals(other.fechaVencimiento)) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (persona == null) { if (other.persona != null) return false; } else if (!persona.equals(other.persona)) return false; if (tipo != other.tipo) return false; if (valor == null) { if (other.valor != null) return false; } else if (!valor.equals(other.valor)) return false; return true; } }