using System.Xml.Serialization;
using Newtonsoft.Json;
using SabreTools.Core;
using SabreTools.Core.Tools;
namespace SabreTools.DatItems.Formats
{
///
/// Represents a blank set from an input DAT
///
[JsonObject("blank"), XmlRoot("blank")]
public sealed class Blank : DatItem
{
#region Fields
/// />
protected override ItemType ItemType => ItemType.Blank;
#endregion
#region Constructors
///
/// Create a default, empty Blank object
///
public Blank()
{
SetFieldValue(Models.Metadata.DatItem.TypeKey, ItemType);
}
#endregion
#region Cloning Methods
///
public override object Clone()
{
var blank = new Blank();
blank.SetFieldValue(DatItem.MachineKey, GetMachine());
blank.SetFieldValue(DatItem.RemoveKey, GetBoolFieldValue(DatItem.RemoveKey));
blank.SetFieldValue(DatItem.SourceKey, GetFieldValue(DatItem.SourceKey));
blank.SetFieldValue(Models.Metadata.DatItem.TypeKey, GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue().AsStringValue());
return blank;
}
#endregion
#region Comparision Methods
///
public override bool Equals(ModelBackedItem? other)
{
// If other is null
if (other == null)
return false;
// If the type is mismatched
if (other is not DatItem otherItem)
return false;
// Compare internal models
return Equals(otherItem);
}
///
public override bool Equals(ModelBackedItem? other)
{
// If other is null
if (other == null)
return false;
// If the type is mismatched
if (other is not DatItem otherItem)
return false;
// Compare internal models
return Equals(otherItem);
}
///
public override bool Equals(DatItem? other)
{
// If we don't have a blank, return false
if (GetStringFieldValue(Models.Metadata.DatItem.TypeKey) != other?.GetStringFieldValue(Models.Metadata.DatItem.TypeKey))
return false;
// Otherwise, treat it as a Blank
Blank? newOther = other as Blank;
// If the machine information matches
return GetMachine() == newOther!.GetMachine();
}
#endregion
}
}