65 lines
1.6 KiB
C#
65 lines
1.6 KiB
C#
using Luban.Job.Cfg.DataVisitors;
|
|
|
|
namespace Luban.Job.Cfg.Datas
|
|
{
|
|
public class DShort : DType<short>
|
|
{
|
|
public static DShort Default { get; } = new DShort(0);
|
|
|
|
public static DShort ValueOf(short x)
|
|
{
|
|
return x == 0 ? Default : new DShort(x);
|
|
}
|
|
|
|
public override string TypeName => "short";
|
|
|
|
private DShort(short x) : base(x)
|
|
{
|
|
}
|
|
|
|
public override void Apply<T>(IDataActionVisitor<T> visitor, T x)
|
|
{
|
|
visitor.Accept(this, x);
|
|
}
|
|
|
|
public override void Apply<T1, T2>(IDataActionVisitor<T1, T2> visitor, T1 x, T2 y)
|
|
{
|
|
visitor.Accept(this, x, y);
|
|
}
|
|
|
|
public override TR Apply<TR>(IDataFuncVisitor<TR> visitor)
|
|
{
|
|
return visitor.Accept(this);
|
|
}
|
|
|
|
public override TR Apply<T, TR>(IDataFuncVisitor<T, TR> visitor, T x)
|
|
{
|
|
return visitor.Accept(this, x);
|
|
}
|
|
|
|
public override TR Apply<T1, T2, TR>(IDataFuncVisitor<T1, T2, TR> visitor, T1 x, T2 y)
|
|
{
|
|
return visitor.Accept(this, x, y);
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
return obj is DShort o && o.Value == this.Value;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return Value.GetHashCode();
|
|
}
|
|
|
|
public override int CompareTo(DType other)
|
|
{
|
|
if (other is DShort d)
|
|
{
|
|
return this.Value.CompareTo(d.Value);
|
|
}
|
|
throw new System.NotSupportedException();
|
|
}
|
|
}
|
|
}
|