Files

86 lines
2.7 KiB
C#
Raw Permalink Normal View History

using System;
2025-09-26 10:20:48 -04:00
using System.Xml.Serialization;
using Newtonsoft.Json;
2025-09-26 13:06:18 -04:00
namespace SabreTools.Data.Models.Metadata
2025-09-26 10:20:48 -04:00
{
[JsonObject("adjuster"), XmlRoot("adjuster")]
public class Adjuster : DatItem, ICloneable, IEquatable<Adjuster>
2025-09-26 10:20:48 -04:00
{
2026-04-01 13:18:45 -04:00
#region Properties
2026-04-09 21:13:55 -04:00
/// <remarks>Condition subitem</remarks>
public string? ConditionMask { get; set; }
/// <remarks>Condition subitem, (eq|ne|gt|le|lt|ge)</remarks>
public Relation? ConditionRelation { get; set; }
/// <remarks>Condition subitem</remarks>
public string? ConditionTag { get; set; }
/// <remarks>Condition subitem</remarks>
public string? ConditionValue { get; set; }
2026-04-01 21:59:16 -04:00
/// <remarks>(yes|no) "no"</remarks>
2026-04-01 16:52:55 -04:00
public bool? Default { get; set; }
2026-04-01 13:18:45 -04:00
public string? Name { get; set; }
#endregion
public Adjuster() => ItemType = ItemType.Adjuster;
/// <inheritdoc/>
public object Clone()
{
var obj = new Adjuster();
2026-04-09 21:13:55 -04:00
obj.ConditionMask = ConditionMask;
obj.ConditionRelation = ConditionRelation;
obj.ConditionTag = ConditionTag;
obj.ConditionValue = ConditionValue;
obj.Default = Default;
obj.Name = Name;
return obj;
}
/// <inheritdoc/>
public bool Equals(Adjuster? other)
{
// Null never matches
if (other is null)
return false;
// Properties
2026-04-09 21:13:55 -04:00
if ((ConditionMask is null) ^ (other.ConditionMask is null))
return false;
else if (ConditionMask is not null && !ConditionMask.Equals(other.ConditionMask, StringComparison.OrdinalIgnoreCase))
return false;
2026-04-09 21:13:55 -04:00
if (ConditionRelation != other.ConditionRelation)
return false;
2026-04-09 21:13:55 -04:00
if ((ConditionTag is null) ^ (other.ConditionTag is null))
return false;
else if (ConditionTag is not null && !ConditionTag.Equals(other.ConditionTag, StringComparison.OrdinalIgnoreCase))
return false;
2026-04-09 21:13:55 -04:00
if ((ConditionValue is null) ^ (other.ConditionValue is null))
return false;
2026-04-09 21:13:55 -04:00
else if (ConditionValue is not null && !ConditionValue.Equals(other.ConditionValue, StringComparison.OrdinalIgnoreCase))
return false;
if (Default != other.Default)
return false;
if ((Name is null) ^ (other.Name is null))
return false;
else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase))
return false;
return true;
}
2025-09-26 10:20:48 -04:00
}
}