using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;

namespace ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances;

public class InstanceAttributeOverride
{
    /// <summary>Gets or sets the primary key.</summary>
    public int Id { get; set; }
    /// <summary>Gets or sets the foreign key of the owning instance.</summary>
    public int InstanceId { get; set; }
    /// <summary>Gets or sets the attribute name this override targets.</summary>
    public string AttributeName { get; set; }
    /// <summary>Gets or sets the override value, or <c>null</c> to clear a previous override.</summary>
    public string? OverrideValue { get; set; }
    /// <summary>
    /// For <see cref="DataType.List"/> attributes: the scalar type of each
    /// element (String, Int32, Float, Double, Boolean, DateTime). Null for scalar
    /// attributes. The element type is fixed by the base attribute and cannot be
    /// changed on a derived template or instance override.
    /// </summary>
    public DataType? ElementDataType { get; set; }

    /// <summary>Initializes a new <see cref="InstanceAttributeOverride"/> for the given attribute name.</summary>
    /// <param name="attributeName">The name of the attribute to override.</param>
    public InstanceAttributeOverride(string attributeName)
    {
        AttributeName = attributeName ?? throw new ArgumentNullException(nameof(attributeName));
    }
}
