package com.example.tampopo_client.models;

import java.util.ArrayList;
import java.util.List;

public class Chatroom {

    private String chatRoomId;
    private String user0Id;
    private String user1Id;
//    private String newContent;
//    private String chatRoomNumber; // サーバーにも存在するので保持
    private List<Message> message = new ArrayList<>();
    private List<Message> messages = new ArrayList<>();
    private List<String> users = new ArrayList<>();
    private boolean empty;

    // --- コンストラクタ ---
    public Chatroom() {
    }

    public Chatroom(String chatRoomId, String user0Id, String user1Id) {
        this.chatRoomId = chatRoomId;
        this.user0Id = user0Id;
        this.user1Id = user1Id;
        this.users.add(user0Id);
        this.users.add(user1Id);
    }

    // --- Getter / Setter ---
    public String getChatRoomId() {
        return chatRoomId;
    }

    public void setChatRoomId(String chatRoomId) {
        this.chatRoomId = chatRoomId;
    }

    public String getUser0Id() {
        return user0Id;
    }

    public void setUser0Id(String user0Id) {
        this.user0Id = user0Id;
    }

    public String getUser1Id() {
        return user1Id;
    }

    public void setUser1Id(String user1Id) {
        this.user1Id = user1Id;
    }

//    public String getNewContent() {
//        return newContent;
//    }
//
//    public void setNewContent(String newContent) {
//        this.newContent = newContent;
//    }
//
//    public String getChatRoomNumber() {
//        return chatRoomNumber;
//    }
//
//    public void setChatRoomNumber(String chatRoomNumber) {
//        this.chatRoomNumber = chatRoomNumber;
//    }

    public List<Message> getMessage() {
        return message;
    }

    public void setMessage(List<Message> message) {
        this.message = message;
    }

    public List<Message> getMessages() {
        return messages;
    }

    public void setMessages(List<Message> messages) {
        this.messages = messages;
    }

    public List<String> getUsers() {
        return users;
    }

    public void setUsers(List<String> users) {
        this.users = users;
    }

    // --- メッセージ追加 ---
    public void addMessage(String senderId, String content) {
        message.add(new Message(senderId, content));
    }

    // --- ユーザー操作 ---
    public void addUser(String userId) {
        if (!users.contains(userId)) {
            users.add(userId);
        }
    }

    public boolean removeUser(String userId) {
        return users.remove(userId);
    }

    public boolean isEmpty() {
        return empty;
    }

    public void setEmpty(boolean empty) {
        this.empty = empty;
    }

    // --- 内部クラス Message ---
    public static class Message {
        private String senderId;
        private String content;

        public Message() {
        }

        public Message(String senderId, String content) {
            this.senderId = senderId;
            this.content = content;
        }

        public String getSenderId() {
            return senderId;
        }

        public void setSenderId(String senderId) {
            this.senderId = senderId;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }
    }
}