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

public class GenreProportion : ValueObject
{
    public decimal? Proportion { get; private set; }
    [Required]
    public Guid GenreId { get; init; } = default!;

    private GenreProportion() { }

    internal GenreProportion(Guid genreId, decimal? proportion)
    {
        GenreId = genreId;
        Proportion = proportion;
    }

    internal static GenreProportion New(Models.GenreProportion genreProportion) => new()
    {
        GenreId = genreProportion.GenreId,
        Proportion = genreProportion.Proportion,
    };

    public static GenreProportion NewForComparison(Guid genreId, decimal? proportion) => new()
    {
        GenreId = genreId,
        Proportion = proportion,
    };

    public void SetProportion(decimal? proportion)
    {
        Proportion = proportion;
    }

    protected override IEnumerable<object?> GetEqualityComponents()
    {
        yield return GenreId;
        yield return Proportion;
    }
}