Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 259 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.beans.Transient; |
||
| 4 | import java.io.Serializable; |
||
| 5 | |||
| 6 | import javax.persistence.Column; |
||
| 7 | import javax.persistence.Entity; |
||
| 8 | import javax.persistence.GeneratedValue; |
||
| 9 | import javax.persistence.GenerationType; |
||
| 10 | import javax.persistence.Id; |
||
| 11 | import javax.persistence.SequenceGenerator; |
||
| 12 | import javax.persistence.Table; |
||
| 13 | import javax.validation.constraints.NotNull; |
||
| 14 | import javax.validation.constraints.Size; |
||
| 15 | |||
| 16 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 17 | |||
| 18 | import br.com.ec.core.interfaces.Alterar; |
||
| 19 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 20 | import br.com.ec.core.util.StringUtil; |
||
| 21 | |||
| 22 | @Entity |
||
| 23 | @Table(name="sec_conta_bancaria", schema="sc_sec") |
||
| 24 | public class ContaBancaria implements Serializable { |
||
| 25 | |||
| 26 | private static final long serialVersionUID = 1L; |
||
| 27 | private static final long CONTA_CAIXA = 1L; |
||
| 28 | |||
| 29 | private Long sequencial; |
||
| 30 | private String descricao; |
||
| 31 | private Boolean ativo; |
||
| 32 | |||
| 33 | public ContaBancaria() {} |
||
| 34 | |||
| 35 | public ContaBancaria(Long sequencial) { |
||
| 36 | this.sequencial = sequencial; |
||
| 37 | } |
||
| 38 | |||
| 39 | @Id |
||
| 40 | @SequenceGenerator(name = "sq_contabancaria") |
||
| 41 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 42 | @Column(name="seq_conta_bancaria", nullable=false) |
||
| 43 | public Long getSequencial() { |
||
| 44 | return sequencial; |
||
| 45 | } |
||
| 46 | public void setSequencial(Long sequencial) { |
||
| 47 | this.sequencial = sequencial; |
||
| 48 | } |
||
| 49 | |||
| 50 | @Column(name="dsc_descricao") |
||
| 51 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 52 | @NotNull(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 53 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 54 | public String getDescricao() { |
||
| 55 | return descricao; |
||
| 56 | } |
||
| 57 | public void setDescricao(String descricao) { |
||
| 58 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 59 | } |
||
| 60 | |||
| 61 | @Column(name="ind_ativo", nullable=false) |
||
| 62 | public Boolean getAtivo() { |
||
| 63 | return ativo; |
||
| 64 | } |
||
| 65 | |||
| 66 | public void setAtivo(Boolean ativo) { |
||
| 67 | this.ativo = ativo; |
||
| 68 | } |
||
| 69 | |||
| 70 | @Transient |
||
| 71 | public static long getContaCaixa() { |
||
| 72 | return CONTA_CAIXA; |
||
| 73 | } |
||
| 74 | |||
| 75 | @Override |
||
| 76 | public int hashCode() { |
||
| 77 | final int prime = 31; |
||
| 78 | int result = 1; |
||
| 79 | result = prime * result |
||
| 80 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 81 | return result; |
||
| 82 | } |
||
| 83 | |||
| 84 | @Override |
||
| 85 | public boolean equals(Object obj) { |
||
| 86 | if (this == obj) |
||
| 87 | return true; |
||
| 88 | if (obj == null) |
||
| 89 | return false; |
||
| 90 | if (getClass() != obj.getClass()) |
||
| 91 | return false; |
||
| 92 | ContaBancaria other = (ContaBancaria) obj; |
||
| 93 | if (sequencial == null) { |
||
| 94 | if (other.sequencial != null) |
||
| 95 | return false; |
||
| 96 | } else if (!sequencial.equals(other.sequencial)) |
||
| 97 | return false; |
||
| 98 | return true; |
||
| 99 | } |
||
| 100 | |||
| 101 | } |