Example #1
0
 protected override void decorateIdentity(CsList <object> identifiers)
 {
     identifiers.Add(_underline);
     identifiers.Add(_italic);
     identifiers.Add(_bold);
     identifiers.Add(_fontSize);
     identifiers.Add(_fontSizeUnit);
     identifiers.Add(_alignment);
     identifiers.Add(_backgroundColor);
     identifiers.Add(_foregroundColor);
 } // decorateIdentity()
Example #2
0
        } // classEquals()

        /**
         * {@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))
                {
                    CsList <object> list1 = new CsList <object>();
                    CsList <object> list2 = new CsList <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 (EnumerableUtils.IsEmpty <object>(list1))
                    {
                        Debug.Assert(EnumerableUtils.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);
        } // equals()
Example #3
0
        } // ToString()

        /**
         * {@inheritDoc}
         */
        public int hashCode()
        {
            logger.debug("{}.hashCode()", this);
            int             hash_code = -1;
            CsList <object> list      = new CsList <object>();

            decorateIdentity(list);
            if (EnumerableUtils.IsEmpty <object>(list))
            {
                list.Add(ToString());
            }
            hash_code -= list.Count;
            foreach (object obj in list)
            {
                hash_code += hashCode(obj);
            }
            return(hash_code);
        } // hashCode()
Example #4
0
 public static CsList <T> List <T>(CsList <T> list, T item)
 {
     list.Add(item); return(list);
 }