package com.pablotj.ai.chat.domain.model;

/**
 * Enumeration representing the role of a message participant.
 */
public enum MessageRole {

    USER("user", "Human user input"),
    ASSISTANT("assistant", "AI assistant response"),
    SYSTEM("system", "System-generated message");

    private final String code;
    private final String description;

    MessageRole(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static MessageRole fromCode(String code) {
        for (MessageRole role : values()) {
            if (role.code.equals(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Unknown message role code: " + code);
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public boolean isUser() {
        return this == USER;
    }

    public boolean isAssistant() {
        return this == ASSISTANT;
    }

    public boolean isSystem() {
        return this == SYSTEM;
    }
}
