-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatMessage.java
More file actions
61 lines (50 loc) · 1.2 KB
/
ChatMessage.java
File metadata and controls
61 lines (50 loc) · 1.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
import java.io.Serializable;
/**
* ChatMessage class
*
* Models a message for users to send and receive
*
* @author David Sillman
*
* @version 11/8/18
*
*/
final class ChatMessage implements Serializable {
private static final long serialVersionUID = 6898543889087L;
public enum ChatType {
GLOBAL,
COMMAND,
PRIVATE,
CONNECTION
}
private String message;
private ChatType type;
private String recipient;
public ChatMessage() {
this.message = null;
this.type = null;
this.recipient = null;
}
public ChatMessage(ChatType type, String message, String recipient) {
this.type = type;
this.message = message;
this.recipient = recipient;
}
public ChatMessage(ChatType type, String message) {
this(type, message, null);
}
public String getMessage() {
return message;
}
public ChatType getType() {
return type;
}
public String getRecipient() { return recipient; }
@Override
public String toString() {
if (type == ChatType.GLOBAL || type == ChatType.PRIVATE) {
return getMessage();
}
return null;
}
}