Java Code Examples for org.h2.util.StringUtils#isNullOrEmpty()

The following examples show how to use org.h2.util.StringUtils#isNullOrEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LeaveSoundBoardListener.java    From DiscordSoundboard with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes"})
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
    String userDisconnected = event.getMember().getEffectiveName();
    String userDisconnectedId = event.getMember().getId();
    User user = userRepository.findOneByIdOrUsernameIgnoreCase(userDisconnectedId, userDisconnected);
    if (user != null && !StringUtils.isNullOrEmpty(user.getLeaveSound())) {
        bot.playFileInChannel(user.getLeaveSound(), event.getChannelJoined());
    } else {
        //If DB doesn't have a leave sound check for a file
        String fileToPlay = bot.getFileForUser(userDisconnected, false);
        if (!fileToPlay.equals("")) {
            try {
                bot.playFileInChannel(fileToPlay, event.getChannelLeft());
            } catch (Exception e) {
                LOG.fatal("Could not play file for disconnection of " + userDisconnected);
            }
        } else {
            LOG.debug("Could not find disconnection sound for " + userDisconnected + ", so ignoring disconnection event.");
        }
    }
}
 
Example 2
Source File: EntranceSoundBoardListener.java    From DiscordSoundboard with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes"})
public void onGuildVoiceJoin(GuildVoiceJoinEvent event) {
    if (!event.getMember().getUser().isBot()) {
        String userJoined = event.getMember().getEffectiveName();
        String userId = event.getMember().getId();

        User user = userRepository.findOneByIdOrUsernameIgnoreCase(userId, userJoined);
        if (user != null && !StringUtils.isNullOrEmpty(user.getEntranceSound())) {
            bot.playFileInChannel(user.getEntranceSound(), event.getChannelJoined());
        } else {
            //If DB doesn't have an entrance sound check for a file.
            String entranceFile = bot.getFileForUser(userJoined, true);
            if (!entranceFile.equals("")) {
                try {
                    bot.playFileInChannel(entranceFile, event.getChannelJoined());
                } catch (Exception e) {
                    LOG.fatal("Could not play file for entrance of " + userJoined);
                }

            } else {

                LOG.debug("Could not find any sound that starts with " + userJoined + ", so ignoring entrance.");
            }
        }
    }
}
 
Example 3
Source File: RoomServiceImpl.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
public Room findByRoomNumber(String roomNumber) {
	if (!StringUtils.isNullOrEmpty(roomNumber) && StringUtils.isNumber(roomNumber)) {
		Room room = repo.findByRoomNumber(roomNumber);
		if (room == null) {
			throw new RoomServiceClientException("Room number: " + roomNumber + ", does not exist.");
		}
		return room;
	}
	else {
		throw new RoomServiceClientException("Room number: " + roomNumber + ", is an invalid room number format.");
	}
}
 
Example 4
Source File: RoomServiceImpl.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
public Room findByRoomNumber(String roomNumber) {
	if (!StringUtils.isNullOrEmpty(roomNumber) && StringUtils.isNumber(roomNumber)) {
		Room room = repo.findByRoomNumber(roomNumber);
		if (room == null) {
			throw new RoomServiceClientException("Room number: " + roomNumber + ", does not exist.");
		}
		return room;
	}
	else {
		throw new RoomServiceClientException("Room number: " + roomNumber + ", is an invalid room number format.");
	}
}
 
Example 5
Source File: RoomServiceImpl.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
public Room findByRoomNumber(String roomNumber) {
	if (!StringUtils.isNullOrEmpty(roomNumber) && StringUtils.isNumber(roomNumber)) {
		Room room = repo.findByRoomNumber(roomNumber);
		if (room == null) {
			throw new RoomServiceClientException("Room number: " + roomNumber + ", does not exist.");
		}
		return room;
	}
	else {
		throw new RoomServiceClientException("Room number: " + roomNumber + ", is an invalid room number format.");
	}
}
 
Example 6
Source File: RoomServiceImpl.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
public Room findByRoomNumber(String roomNumber) {
	if (!StringUtils.isNullOrEmpty(roomNumber) && StringUtils.isNumber(roomNumber)) {
		Room room = repo.findByRoomNumber(roomNumber);
		if (room == null) {
			throw new RoomServiceClientException("Room number: " + roomNumber + ", does not exist.");
		}
		return room;
	}
	else {
		throw new RoomServiceClientException("Room number: " + roomNumber + ", is an invalid room number format.");
	}
}