54 lines
1.5 KiB
Java
54 lines
1.5 KiB
Java
package envoy.data;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
/**
|
|
* Represents a {@link Message} with content that is comprised of text.<br>
|
|
* <br>
|
|
* Project: <strong>envoy-common</strong><br>
|
|
* File: <strong>TextMessage.java</strong><br>
|
|
* Created: <strong>28.12.2019</strong><br>
|
|
*
|
|
* @author Kai S. K. Engelbart
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
public class TextMessage extends Message {
|
|
|
|
private final String content;
|
|
|
|
private static final long serialVersionUID = 1538164720632899917L;
|
|
|
|
/**
|
|
* Initializes a {@link TextMessage} from the client's perspective. The current
|
|
* date
|
|
* is used as the message date and the status is set to
|
|
* {@link MessageStatus#WAITING}.
|
|
*
|
|
* @param id unique ID
|
|
* @param sender the user who sends the message
|
|
* @param recipient the user who receives the message
|
|
* @param content the content of the message
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
public TextMessage(long id, User sender, User recipient, String content) {
|
|
super(id, sender, recipient);
|
|
this.content = content;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format("TextMessage[id=%d,sender=%s,recipient=%s,date=%s,status=%s,content=%s]",
|
|
getId(),
|
|
getSender(),
|
|
getRecipient(),
|
|
new SimpleDateFormat("dd.MM.yyyy hh:mm:ss").format(getDate()),
|
|
getStatus(),
|
|
content);
|
|
}
|
|
|
|
/**
|
|
* @return the content of this {@link TextMessage}
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
public String getContent() { return content; }
|
|
} |