using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Enums;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities
{
    /// 
    /// An entity representing a preference attached to a user or group.
    /// 
    public class Preference : IHasConcurrencyToken
    {
        /// 
        /// Initializes a new instance of the  class.
        /// Public constructor with required data.
        /// 
        /// The preference kind.
        /// The value.
        public Preference(PreferenceKind kind, string value)
        {
            Kind = kind;
            Value = value ?? throw new ArgumentNullException(nameof(value));
        }
        /// 
        /// Gets the id of this preference.
        /// 
        /// 
        /// Identity, Indexed, Required.
        /// 
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; private set; }
        /// 
        /// Gets or sets the id of the associated user.
        /// 
        public Guid? UserId { get; set; }
        /// 
        /// Gets the type of this preference.
        /// 
        /// 
        /// Required.
        /// 
        public PreferenceKind Kind { get; private set; }
        /// 
        /// Gets or sets the value of this preference.
        /// 
        /// 
        /// Required, Max length = 65535.
        /// 
        [MaxLength(65535)]
        [StringLength(65535)]
        public string Value { get; set; }
        /// 
        [ConcurrencyCheck]
        public uint RowVersion { get; private set; }
        /// 
        public void OnSavingChanges()
        {
            RowVersion++;
        }
    }
}