package org.ntlab.tampoposerver.models;
import java.util.ArrayList;
import java.util.List;
public class ChatRooms {
private String chatRoomId;
private String user0Id;
private String user1Id;
private String newContent;
private String chatRoomNumber;
private List<Message> messages = new ArrayList<>();
private List<String> users = new ArrayList<>();
public ChatRooms(String chatRoomId, String user0Id, String user1Id) {
this.chatRoomId = chatRoomId;
this.user0Id = user0Id;
this.user1Id = user1Id;
this.users.add(user0Id);
this.users.add(user1Id);
}
public String getUser0Id() {
return user0Id;
}
public String getUser1Id() {
return user1Id;
}
public String getChatRoomId() {
return chatRoomId;
}
public void setChatRoomId(String chatRoomId) {
this.chatRoomId = chatRoomId;
}
public void addUser(String userId) {
if (!users.contains(userId)) {
users.add(userId);
}
}
public List<String> getUsers() {
return new ArrayList<>(users);
}
public void put(Integer chatRoomId, String chatRoomNumber) {
}
// public Integer updateMessage() {
// return chatRoomId;
// }
public ChatRooms updateMessage(String chatRoomId, String userId, String newContent) {
this.chatRoomId = chatRoomId;
this.user0Id = userId;
this.newContent = newContent;
return this;
}
public ChatRooms addMessage(String senderId, String content) {
messages.add(new Message(senderId, content));
return this;
}
public List<Message> getMessages() {
return messages;
}
public List<Message> getMessage() {
return messages;
}
public static class Message {
private String senderId;
private String content;
public Message(String senderId, String content) {
this.senderId = senderId;
this.content = content;
}
public String getSenderId() {
return senderId;
}
public String getContent() {
return content;
}
}
public boolean removeUser(String userId) {
return users.remove(userId);
}
public boolean isEmpty() {
return users.isEmpty();
}
}