45 lines
1.2 KiB
Java
45 lines
1.2 KiB
Java
package envoy.client;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import javax.swing.DefaultListModel;
|
|
|
|
import envoy.schema.Message;
|
|
import envoy.schema.User;
|
|
|
|
public class Chat implements Serializable {
|
|
|
|
private static final long serialVersionUID = -7751248474547242056L;
|
|
|
|
private User recipient;
|
|
private DefaultListModel<Message> model = new DefaultListModel<>();
|
|
|
|
/**
|
|
* Provides the list of messages that the recipient receives.<br>
|
|
* Saves the Messages in the corresponding chat at that Point.
|
|
*
|
|
* @param recipient the user who receives the messages
|
|
* @since Envoy v0.1-alpha
|
|
*/
|
|
public Chat(User recipient) { this.recipient = recipient; }
|
|
|
|
/**
|
|
* @return the recipient of a message
|
|
* @since Envoy v0.1-alpha
|
|
*/
|
|
public User getRecipient() { return recipient; }
|
|
|
|
/**
|
|
* Adds the received message at the current Point in the current chat
|
|
*
|
|
* @param message the message to add in said chat
|
|
* @since Envoy v0.1-alpha
|
|
*/
|
|
public void appendMessage(Message message) { model.addElement(message); }
|
|
|
|
/**
|
|
* @return all messages in the current chat
|
|
* @since Envoy v0.1-alpha
|
|
*/
|
|
public DefaultListModel<Message> getModel() { return model; }
|
|
} |