public boolean isSame()

in src/main/java/org/apache/sling/testing/mock/jcr/AbstractItem.java [110:130]


    public boolean isSame(final Item otherItem) throws RepositoryException {
        boolean same = false;
        // Both objects were acquired through Session objects that were created by the same Repository object.
        // Both objects were acquired through Session objects bound to the same repository workspace.
        if (Objects.equals(getSession().getRepository(), otherItem.getSession().getRepository()) &&
                Objects.equals(getSession().getWorkspace().getName(), otherItem.getSession().getWorkspace().getName())) {
            // The objects are either both Node objects or both Property objects.
            if (isNode() && otherItem.isNode()) {
                // they are Node objects, they must have the same identifier.
                if (Objects.equals(((Node)this).getIdentifier(), ((Node)otherItem).getIdentifier())) {
                    same = true;
                }
            } else if (!isNode() && !otherItem.isNode() &&
                    // Property objects must have identical names and isSame is true of their parent nodes.
                    Objects.equals(getName(), otherItem.getName()) &&
                    getParent().isSame(otherItem.getParent())) {
                same = true;
            }
        }
        return same;
    }