Subversion Repositories Integrator Subversion

Rev

Rev 760 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
760 blopes 1
package br.com.sl.domain.model;
2
 
3
import java.io.Serializable;
4
 
5
import javax.persistence.Column;
6
import javax.persistence.Entity;
7
import javax.persistence.GeneratedValue;
8
import javax.persistence.GenerationType;
9
import javax.persistence.Id;
10
import javax.persistence.SequenceGenerator;
11
import javax.persistence.Table;
12
import javax.validation.constraints.Size;
13
 
14
import org.hibernate.validator.constraints.NotEmpty;
15
 
16
import br.com.ec.core.interfaces.Alterar;
17
import br.com.ec.core.interfaces.Cadastrar;
18
import br.com.ec.core.util.StringUtil;
19
 
20
@Entity
21
@Table(name="slp_ativo", schema="sc_slp")
22
public class Ativo implements Serializable {
23
 
24
        private static final long serialVersionUID = 1L;
25
 
26
        private Long sequencial;
27
        private String nome;
28
 
771 blopes 29
        public Ativo() {}
30
 
31
        public Ativo(Long sequencial, String nome) {
32
                this.sequencial = sequencial;
33
                this.nome = nome;
34
        }
35
 
760 blopes 36
        @Id
37
        @SequenceGenerator(name = "sq_ativo")
38
        @GeneratedValue(strategy=GenerationType.IDENTITY)
39
        @Column(name="seq_ativo", nullable=false)
40
        public Long getSequencial() {
41
                return sequencial;
42
        }
43
        public void setSequencial(Long sequencial) {
44
                this.sequencial = sequencial;
45
        }
46
 
47
        @Column(name="dsc_ativo")
48
        @Size(max = 120, message = "Limite de caracteres ultrapassado: Nome do ativo")
49
        @NotEmpty(message="Obrigatório informar o nome do ativo", groups={Cadastrar.class, Alterar.class})
50
        public String getNome() {
51
                return nome;
52
        }
53
        public void setNome(String nome) {
54
                this.nome = StringUtil.setarUpperCaseComTrim(nome);
55
        }
56
 
771 blopes 57
        @Override
58
        public int hashCode() {
59
                final int prime = 31;
60
                int result = 1;
61
                result = prime * result
62
                                + ((sequencial == null) ? 0 : sequencial.hashCode());
63
                return result;
64
        }
65
 
66
        @Override
67
        public boolean equals(Object obj) {
68
                if (this == obj)
69
                        return true;
70
                if (obj == null)
71
                        return false;
72
                if (getClass() != obj.getClass())
73
                        return false;
74
                Ativo other = (Ativo) obj;
75
                if (sequencial == null) {
76
                        if (other.sequencial != null)
77
                                return false;
78
                } else if (!sequencial.equals(other.sequencial))
79
                        return false;
80
                return true;
81
        }
82
 
760 blopes 83
}