using Modules.Library.Domain.Entities.Language;

namespace Modules.Library.Domain.EntityBuilders;

public class LanguageBuilder : EntityBuilder<Language>
{
    private static readonly Func<Language> CreateInstanceFunc = CreateInstanceFunction();
    private static readonly Action<LanguageBuilder, Language> SetInstanceFieldsAction = SetInstanceFieldsAction<LanguageBuilder>();

    private readonly string _codeIso2;
    private readonly string _name;
    private Guid? _iconId;

    public LanguageBuilder(string codeIso2, string name)
    {
        _codeIso2 = codeIso2;
        _name = name;
    }

    public LanguageBuilder WithIcon(Guid iconId)
    {
        _iconId = iconId;
        return this;
    }

    public override Language Build()
    {
        var result = CreateInstanceFunc();
        SetInstanceFieldsAction(this, result);
        return result;
    }
}
