Example #1
0
        /**
         * Compares two STUN Attributes. Attributeas are considered equal when their
         * type, length, and all data are the same.
         *
         * @param obj the object to compare this attribute with.
         * @return true if the attributes are equal and false otherwise.
         */
        public override bool Equals(Object obj)
        {
            if (!(obj is ErrorCodeAttribute) ||
                obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            ErrorCodeAttribute att = (ErrorCodeAttribute)obj;

            if (att.GetAttributeType() != GetAttributeType() ||
                att.GetDataLength() != GetDataLength()
                //compare data
                || att.GetErrorClass() != GetErrorClass() ||
                att.GetErrorNumber() != GetErrorNumber() ||
                (att.GetReasonPhrase() != null &&
                 !att.GetReasonPhrase().Equals(GetReasonPhrase()))
                )
            {
                return(false);
            }

            return(true);
        }