702 }
703
704 /**
705 * Test the equality of two HTTP cookies.
706 *
707 * <p> The result is {@code true} only if two cookies come from same domain
708 * (case-insensitive), have same name (case-insensitive), and have same path
709 * (case-sensitive).
710 *
711 * @return {@code true} if two HTTP cookies equal to each other;
712 * otherwise, {@code false}
713 */
714 @Override
715 public boolean equals(Object obj) {
716 if (obj == this)
717 return true;
718 if (!(obj instanceof HttpCookie))
719 return false;
720 HttpCookie other = (HttpCookie)obj;
721
722 // One http cookie equals to another cookie (RFC 2965 sec. 3.3.3) if:
723 // 1. they come from same domain (case-insensitive),
724 // 2. have same name (case-insensitive),
725 // 3. and have same path (case-sensitive).
726 return equalsIgnoreCase(getName(), other.getName()) &&
727 equalsIgnoreCase(getDomain(), other.getDomain()) &&
728 Objects.equals(getPath(), other.getPath());
729 }
730
731 /**
732 * Returns the hash code of this HTTP cookie. The result is the sum of
733 * hash code value of three significant components of this cookie: name,
734 * domain, and path. That is, the hash code is the value of the expression:
735 * <blockquote>
736 * getName().toLowerCase().hashCode()<br>
737 * + getDomain().toLowerCase().hashCode()<br>
738 * + getPath().hashCode()
739 * </blockquote>
740 *
741 * @return this HTTP cookie's hash code
742 */
|
702 }
703
704 /**
705 * Test the equality of two HTTP cookies.
706 *
707 * <p> The result is {@code true} only if two cookies come from same domain
708 * (case-insensitive), have same name (case-insensitive), and have same path
709 * (case-sensitive).
710 *
711 * @return {@code true} if two HTTP cookies equal to each other;
712 * otherwise, {@code false}
713 */
714 @Override
715 public boolean equals(Object obj) {
716 if (obj == this)
717 return true;
718 if (!(obj instanceof HttpCookie))
719 return false;
720 HttpCookie other = (HttpCookie)obj;
721
722 // One http cookie is equal to another cookie (RFC 2965 sec. 3.3.3) if:
723 // 1. they come from same domain (case-insensitive),
724 // 2. have same name (case-insensitive),
725 // 3. and have same path (case-sensitive).
726 return equalsIgnoreCase(getName(), other.getName()) &&
727 equalsIgnoreCase(getDomain(), other.getDomain()) &&
728 Objects.equals(getPath(), other.getPath());
729 }
730
731 /**
732 * Returns the hash code of this HTTP cookie. The result is the sum of
733 * hash code value of three significant components of this cookie: name,
734 * domain, and path. That is, the hash code is the value of the expression:
735 * <blockquote>
736 * getName().toLowerCase().hashCode()<br>
737 * + getDomain().toLowerCase().hashCode()<br>
738 * + getPath().hashCode()
739 * </blockquote>
740 *
741 * @return this HTTP cookie's hash code
742 */
|