private void checkJoinRoomPreconditionNicknameInUse(@Nonnull final JID realAddress, @Nonnull String nickname) throws UserAlreadyExistsException
    {
        final JID bareJID = realAddress.asBareJID();
        final boolean canJoin = occupants.stream().noneMatch(occupant -> !occupant.getUserAddress().asBareJID().equals(bareJID) && occupant.getNickname().equalsIgnoreCase(nickname));
        Log.trace( "{} Room join precondition 'nickname in use': User '{}' {} join room '{}'.", canJoin ? "PASS" : "FAIL", realAddress, canJoin ? "can" : "cannot", this.getJID() );
        if (!canJoin) {
            throw new UserAlreadyExistsException( "Someone else in the room uses the nickname that you want to use." );
        }
    }
Checks if the nickname that the user attempts to use is already used by someone else in the room.

@param realAddress The address of the user that attempts to join.
@param nickname The nickname that the user is attempting to use
@throws UserAlreadyExistsException when joining is prevented by virtue of someone else in the room using the nickname.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoom.java