using Luban.Job.Cfg.DataVisitors; using Luban.Job.Cfg.Defs; using Luban.Job.Cfg.Utils; using Luban.Job.Common.Types; using System.Collections.Generic; namespace Luban.Job.Cfg.Datas { public class DBean : DType { public TBean TType { get; } public DefBean Type => (DefBean)TType.Bean; public DefBean ImplType { get; } public List Fields { get; } public override string TypeName => "bean"; public DBean(TBean defType, DefBean implType, List fields) { this.TType = defType; this.ImplType = implType; this.Fields = fields; } public override bool Equals(object obj) { return obj is DBean d && string.Equals(ImplType?.FullName, d.ImplType?.FullName) && DataUtil.IsCollectionEqual(Fields, d.Fields); } public override int GetHashCode() { throw new System.NotSupportedException(); } public override int CompareTo(DType other) { throw new System.NotSupportedException(); } public DType GetField(string fieldName) { if (ImplType.TryGetField(fieldName, out var _, out var findex)) { return Fields[findex]; } else { return null; } } public override void Apply(IDataActionVisitor visitor, T x) { visitor.Accept(this, x); } public override void Apply(IDataActionVisitor visitor, T1 x, T2 y) { visitor.Accept(this, x, y); } public override TR Apply(IDataFuncVisitor visitor) { return visitor.Accept(this); } public override TR Apply(IDataFuncVisitor visitor, T x) { return visitor.Accept(this, x); } } }