public boolean exists(@Nonnull final Occupant occupant, @Nullable final NodeID exclude)
    {
        mutex.readLock().lock();
        try {
            if (occupant.isFederated()) {
                return federatedOccupants.getOrDefault(occupant.getRealJID(), Collections.emptySet()).contains(occupant);
            } else {
                final NodeID node = nodeByLocalOccupant.get(occupant);
                if (node == null) {
                    return false;
                }
                return !node.equals(exclude);
            }
        } finally {
            mutex.readLock().unlock();
        }
    }
Checks whether the occupant exists, optionally excluding a specific node from evaluation.

@param occupant The subject of the existence check
@param exclude An optional node to exclude from the check
@return True if the occupant was found, otherwise false.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/spi/OccupantManager.java