
namespace Modules.Library.Domain.Entities.MediaContent.CommonProperties;

public class NameItem : ValueObject
{
    [Required]
    public string Value { get; private set; } = string.Empty;
    public NameType Type { get; private init; }
    [Required]
    public Guid LanguageId { get; private set; } = default!;

    private NameItem() { }

    public NameItem(NameType type, Guid languageId, string value)
    {
        Type = type;
        LanguageId = languageId;
        Value = value;
    }

    internal NameItem(Guid languageId, NameType type, string value)
    {
        LanguageId = languageId;
        Type = type;
        Value = value;
    }

    public static NameItem New(Models.NameItem nameItem) => new()
    {
        Type = nameItem.Type,
        LanguageId = nameItem.LanguageId,
        Value = nameItem.Value,
    };

    public void SetValue(string value)
    {
        Value = value;
    }

    public void SetLanguage(Guid languageId)
    {
        LanguageId = languageId;
    }

    protected override IEnumerable<object?> GetEqualityComponents()
    {
        yield return Type;
        yield return LanguageId;
        yield return Value;
    }
}

public enum NameType
{
    Original,
    OriginalInAnotherLanguage,
    Translation,
    Abbreviation,
}