added Javadoc in Class Message
This commit is contained in:
parent
7e7333dfaf
commit
56200b749d
|
@ -1,11 +1,21 @@
|
|||
package ch.zhaw.pm2.multichat.client;
|
||||
|
||||
/**
|
||||
A Message object represents one Message of a client. Can be stored in ClientMessageList.
|
||||
*/
|
||||
public class Message {
|
||||
private MessageType type;
|
||||
private String sender;
|
||||
private String receiver;
|
||||
private String text;
|
||||
|
||||
/**
|
||||
* Constructor of Message. Needs all Information about a Message to save them.
|
||||
* @param type Message (if it's a message typed by a user), Error or Information (if it is generated automatically, in this case sender and reciever will be null)
|
||||
* @param sender The User who has sent the message.
|
||||
* @param receiver The User who should recieve the message.
|
||||
* @param text The Text of the message.
|
||||
*/
|
||||
public Message(MessageType type, String sender, String receiver, String text) {
|
||||
this.type = type;
|
||||
this.sender = sender;
|
||||
|
@ -13,28 +23,48 @@ public class Message {
|
|||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the Filter String is contained in one of the datafields sender, receiver or text
|
||||
* @param filter The Filter String
|
||||
* @return true if it the Filter String is contained in a datafield.
|
||||
*/
|
||||
public boolean matchesFilter(String filter){
|
||||
return (sender != null && sender.contains(filter)) ||
|
||||
(receiver != null && receiver.contains(filter)) ||
|
||||
(text != null && text.contains(filter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The type of the message.
|
||||
*/
|
||||
public MessageType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The User who has sent the Message.
|
||||
*/
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Reciever who recieves the Message.
|
||||
*/
|
||||
public String getReceiver() {
|
||||
return receiver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Text of the Message.
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enummeration of Message Types.
|
||||
*/
|
||||
public enum MessageType {
|
||||
INFO, MESSAGE, ERROR;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue