forked from hmhallan/andorinha-backend
/
Tweet.java
102 lines (92 loc) · 2.37 KB
/
Tweet.java
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package model;
import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "tweet")
public class Tweet {
@Id
@SequenceGenerator(name = "seq_tweet", sequenceName = "seq_tweet", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tweet")
@Column(name = "id")
private int id;
@Column(name = "conteudo")
private String conteudo;
@Column(name = "data_postagem")
@Temporal(TemporalType.TIMESTAMP)
private Calendar data;
@ManyToOne
@JoinColumn(name = "id_usuario", referencedColumnName = "id")
private Usuario usuario;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getConteudo() {
return conteudo;
}
public void setConteudo(String conteudo) {
this.conteudo = conteudo;
}
public Calendar getData() {
return data;
}
public void setData(Calendar data) {
this.data = data;
}
public Usuario getUsuario() {
return usuario;
}
public void setUsuario(Usuario usuario) {
this.usuario = usuario;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((conteudo == null) ? 0 : conteudo.hashCode());
result = prime * result + ((data == null) ? 0 : data.hashCode());
result = prime * result + id;
result = prime * result + ((usuario == null) ? 0 : usuario.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;
Tweet other = (Tweet) obj;
if (conteudo == null) {
if (other.conteudo != null)
return false;
} else if (!conteudo.equals(other.conteudo))
return false;
if (data == null) {
if (other.data != null)
return false;
} else if (!data.equals(other.data))
return false;
if (id != other.id)
return false;
if (usuario == null) {
if (other.usuario != null)
return false;
} else if (!usuario.equals(other.usuario))
return false;
return true;
}
}