This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/src/main/java/envoy/client/Chat.java

57 lines
1.5 KiB
Java
Raw Normal View History

2019-12-21 21:23:19 +01:00
package envoy.client;
import java.io.Serializable;
import envoy.client.ui.list.ComponentListModel;
import envoy.data.Message;
import envoy.data.User;
2019-12-21 21:23:19 +01:00
/**
* Represents a chat between two {@link User}s <br>
* as a list of {@link Message} objects.
* <br>
* Project: <strong>envoy-client</strong><br>
* File: <strong>Chat.java</strong><br>
* Created: <strong>19 Oct 2019</strong><br>
*
* @author Maximilian K&auml;fer
* @author Leon Hofmeister
* @author Kai S. K. Engelbart
* @since Envoy v0.1-alpha
*/
public class Chat implements Serializable {
private static final long serialVersionUID = -7751248474547242056L;
private User recipient;
private ComponentListModel<Message> model = new ComponentListModel<>();
2019-12-21 21:23:19 +01:00
/**
* 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.add(message); }
2019-12-21 21:23:19 +01:00
/**
* @return all messages in the current chat
* @since Envoy v0.1-alpha
*/
public ComponentListModel<Message> getModel() { return model; }
}