| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.om; |
| 9 | |
| 10 | /** |
| 11 | * The IdentityComparable class provides a way to compare class objects for strong equality. |
| 12 | * In some cases it may test for Java-level object identity, but this is not essential. For example, |
| 13 | * with date/time values it checks that the values are not only equal according to the XPath rules, |
| 14 | * but also have the same timezone (or absence of a timezone). |
| 15 | */ |
| 16 | public interface IdentityComparable { |
| 17 | |
| 18 | /** |
| 19 | * Determine whether two IdentityComparable objects are identical. This is a stronger |
| 20 | * test than equality (even schema-equality); for example two dateTime values are not identical unless |
| 21 | * they are in the same timezone. |
| 22 | * |
| 23 | * @param other the value to be compared with |
| 24 | * @return true if the two values are indentical, false otherwise |
| 25 | */ |
| 26 | boolean isIdentical(IdentityComparable other); |
| 27 | |
| 28 | /** |
| 29 | * Get a hashCode that offers the guarantee that if A.isIdentical(B), then A.identityHashCode() == B.identityHashCode() |
| 30 | * @return a hashCode suitable for use when testing for identity. |
| 31 | */ |
| 32 | |
| 33 | int identityHashCode(); |
| 34 | } |