/** * {@inheritDoc} */ public bool equals(object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj is BaseObject) { BaseObject that = (BaseObject) obj; if (classEquals(that)) { NList<object> list1 = new NList<object>(); NList<object> list2 = new NList<object>(); decorateIdentity(list1); that.decorateIdentity(list2); if (list1.Count != list2.Count) { throw new InvalidOperationException("Two instances of the same class (" + GetType().Name + ") returned different size decorated identity lists"); } if (NEnumerableUtils.IsEmpty<object>(list1)) { Debug.Assert(NEnumerableUtils.IsEmpty<object>(list2)); list1.Add(ToString()); list2.Add(that.ToString()); } EqualsBuilder eb = new EqualsBuilder(); while (list1.HasNext()) { Debug.Assert(list2.HasNext()); object next1 = list1.Next(); object next2 = list2.Next(); eb.append(next1, next2); } Debug.Assert(! list2.HasNext()); return eb.isEquals(); } } return false; }