-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEstado.java
More file actions
83 lines (68 loc) · 2 KB
/
Estado.java
File metadata and controls
83 lines (68 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package br.com.openenade.api.estado;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import br.com.openenade.api.regiao.Regiao;
@Entity
public class Estado {
@Id
@NotBlank(message = "Estado 'sigla' não pode ser vazio.")
private String sigla;
@ManyToOne(optional = false)
@NotNull(message = "Estado 'regiao' não pode ser nulo.")
private Regiao regiao;
public Estado() {
}
public Estado(String siglaEstado, Regiao regiaoEstado) {
super();
this.sigla = siglaEstado;
this.regiao = regiaoEstado;
}
public String getSigla() {
return sigla;
}
public void setSigla(String siglaEstado) {
this.sigla = siglaEstado;
}
public Regiao getRegiao() {
return regiao;
}
public void setRegiao(Regiao regiao) {
this.regiao = regiao;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((regiao == null) ? 0 : regiao.hashCode());
result = prime * result + ((sigla == null) ? 0 : sigla.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;
Estado other = (Estado) obj;
if (regiao == null) {
if (other.regiao != null)
return false;
} else if (!regiao.equals(other.regiao))
return false;
if (sigla == null) {
if (other.sigla != null)
return false;
} else if (!sigla.equals(other.sigla))
return false;
return true;
}
@Override
public String toString() {
return "Estado [siglaEstado=" + sigla + ", regiaoEstado=" + regiao + "]";
}
}