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.io.Serializable; |
||
| 4 | |||
| 5 | import javax.persistence.Column; |
||
| 6 | import javax.persistence.Entity; |
||
| 7 | import javax.persistence.Id; |
||
| 8 | import javax.persistence.Table; |
||
| 9 | import javax.persistence.Transient; |
||
| 10 | import javax.validation.constraints.Size; |
||
| 11 | |||
| 12 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 13 | |||
| 14 | import br.com.ec.core.interfaces.Alterar; |
||
| 15 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 16 | import br.com.ec.core.util.StringUtil; |
||
| 17 | import br.com.ec.core.util.VerificadorUtil; |
||
| 18 | import br.com.ec.domain.model.tipos.TipoCartao; |
||
| 19 | |||
| 20 | @Entity |
||
| 21 | @Table(name="sec_bandeira_cartao", schema="sc_sec") |
||
| 22 | public class BandeiraCartao implements Serializable { |
||
| 23 | |||
| 24 | private static final long serialVersionUID = 1L; |
||
| 25 | |||
| 26 | private Long codigo; |
||
| 27 | private String descricao; |
||
| 28 | private String tipoCartao; |
||
| 29 | private Boolean ativo; |
||
| 30 | |||
| 31 | @Id |
||
| 32 | @Column(name="cod_bandeira_cartao", nullable=false) |
||
| 33 | public Long getCodigo() { |
||
| 34 | return codigo; |
||
| 35 | } |
||
| 36 | public void setCodigo(Long codigo) { |
||
| 37 | this.codigo = codigo; |
||
| 38 | } |
||
| 39 | |||
| 40 | @Column(name="dsc_bandeira") |
||
| 41 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 42 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 43 | public String getDescricao() { |
||
| 44 | return descricao; |
||
| 45 | } |
||
| 46 | public void setDescricao(String descricao) { |
||
| 47 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 48 | } |
||
| 49 | |||
| 50 | @Column(name="tip_cartao") |
||
| 51 | public String getTipoCartao() { |
||
| 52 | return tipoCartao; |
||
| 53 | } |
||
| 54 | public void setTipoCartao(String tipoCartao) { |
||
| 55 | this.tipoCartao = tipoCartao; |
||
| 56 | } |
||
| 57 | |||
| 58 | @Column(name="ind_ativo", nullable=false) |
||
| 59 | public Boolean getAtivo() { |
||
| 60 | return ativo; |
||
| 61 | } |
||
| 62 | public void setAtivo(Boolean ativo) { |
||
| 63 | this.ativo = ativo; |
||
| 64 | } |
||
| 65 | |||
| 66 | @Transient |
||
| 67 | public String getTipoCartaoDescricao() { |
||
| 68 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoCartao())? TipoCartao.parse(getTipoCartao()).getDescricao() : null; |
||
| 69 | } |
||
| 70 | |||
| 71 | @Override |
||
| 72 | public int hashCode() { |
||
| 73 | final int prime = 31; |
||
| 74 | int result = 1; |
||
| 75 | result = prime * result |
||
| 76 | + ((codigo == null) ? 0 : codigo.hashCode()); |
||
| 77 | return result; |
||
| 78 | } |
||
| 79 | |||
| 80 | @Override |
||
| 81 | public boolean equals(Object obj) { |
||
| 82 | if (this == obj) |
||
| 83 | return true; |
||
| 84 | if (obj == null) |
||
| 85 | return false; |
||
| 86 | if (getClass() != obj.getClass()) |
||
| 87 | return false; |
||
| 88 | BandeiraCartao other = (BandeiraCartao) obj; |
||
| 89 | if (codigo == null) { |
||
| 90 | if (other.codigo != null) |
||
| 91 | return false; |
||
| 92 | } else if (!codigo.equals(other.codigo)) |
||
| 93 | return false; |
||
| 94 | return true; |
||
| 95 | } |
||
| 96 | |||
| 97 | } |