blob: 2d810557930aca269d8d44cdb32f0afa7d7d154c (
plain)
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
|
package kz.ilotterytea.frogartha.domain;
import com.github.czyzby.websocket.serialization.SerializationException;
import com.github.czyzby.websocket.serialization.Transferable;
import com.github.czyzby.websocket.serialization.impl.Deserializer;
import com.github.czyzby.websocket.serialization.impl.Serializer;
public class Identity implements Transferable<Identity> {
private String username;
private long id;
public Identity() {
}
public Identity(long id, String username) {
this.id = id;
this.username = username;
}
public long getId() {
return id;
}
public String getUsername() {
return username;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Identity) {
Identity i = (Identity) obj;
return i.username.equals(username) && i.id == id;
}
return false;
}
@Override
public String toString() {
return "Identity{" +
"username='" + username + '\'' +
", id=" + id +
'}';
}
@Override
public void serialize(Serializer serializer) throws SerializationException {
serializer.serializeLong(id).serializeString(username);
}
@Override
public Identity deserialize(Deserializer deserializer) throws SerializationException {
return new Identity(deserializer.deserializeLong(), deserializer.deserializeString());
}
}
|