/**
         * {@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;
        }
 /**
  * {@inheritDoc}
  */
 public int hashCode()
 {
     logger.debug("{}.hashCode()", this);
     int hash_code = -1;
     NList<object> list = new NList<object>();
     decorateIdentity(list);
     if (NEnumerableUtils.IsEmpty<object>(list))
     {
         list.Add(ToString());
     }
     hash_code -= list.Count;
     foreach (object obj in list)
     {
         hash_code += hashCode(obj);
     }
     return hash_code;
 }
Beispiel #3
0
        } // constructor

        ///**
        // * Creates a compound filter item based on other filter items. Each provided
        // * filter item will be combined according to the {@link LogicalOperator}.
        // *
        // * @param logicalOperator
        // *            the logical operator to apply
        // * @param items
        // *            an array of items to include in the composite
        // */
        //public FilterItem(LogicalOperator logicalOperator, params FilterItem[] items) :
        //                  this(logicalOperator, Arrays.asList(items))
        //{
        //}

        /**
         * Creates a compound filter item based on other filter items. Each provided
         * filter item will be combined according to the {@link LogicalOperator}.
         *
         * @param logicalOperator
         *            the logical operator to apply
         * @param items
         *            a list of items to include in the composite
         */
        public FilterItem(LogicalOperator logicalOperator, NList <FilterItem> items) :
            this(null, null, null, items, null, logicalOperator)
        {
            require("Child items cannot be null", _childItems != null);
            require("Child items cannot be empty", !NEnumerableUtils.IsEmpty <FilterItem>(_childItems));
        }