當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayUtils.removeAll方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.ArrayUtils.removeAll方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayUtils.removeAll方法的具體用法?Java ArrayUtils.removeAll怎麽用?Java ArrayUtils.removeAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils.removeAll方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: executeWithConfig

import org.apache.commons.lang3.ArrayUtils; //導入方法依賴的package包/類
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    final User user = commandEvent.getAuthor();
    final String userName = user.getName();
    final String[] args = commandEvent.getArgs().split(" ");
    if (args.length < 2) {
        throw new UserMessedUpException(userName,
                localeService.getMessageFor(LocaleService.BAD_SYNTAX, localeService.getLocaleForUser(user),
                        "!raid hatch Ho-Oh solna platform"));
    }
    String pokemonName = args[0].trim().toLowerCase();
    final String[] gymArguments = ArrayUtils.removeAll(args, 0);
    String gymName = StringUtils.join(gymArguments, " ");
    final String region = config.getRegion();
    final Gym gym = gymRepository.search(user, gymName, region);
    final Raid raid = raidRepository.getActiveRaidOrFallbackToExRaid(gym, region, user);

    final Pokemon pokemon = pokemonRepository.search(pokemonName, user);
    final PokemonRaidInfo existingRaidInfo = raidStrategyService.getRaidInfo(raid.getPokemon());
    final int newBossTier = raidStrategyService.getRaidInfo(pokemon).getBossTier();
    if (!raid.getPokemon().isEgg()) {
        throw new UserMessedUpException(user,
                localeService.getMessageFor(LocaleService.EGG_ALREADY_HATCHED,
                        localeService.getLocaleForUser(user), raid.getPokemon().toString()));
    }
    if (pokemon.isEgg() || newBossTier != existingRaidInfo.getBossTier()) {
        throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.EGG_WRONG_TIER,
                localeService.getLocaleForUser(user)));
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Trying to hatch raid " + raid + " into " + pokemonName);
    }
    AlterRaidCommand.changePokemon(this, gymRepository, localeService, pokemonRepository, raidRepository,
            commandEvent, config, user, userName, pokemonName,
            gymArguments);
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:37,代碼來源:EggHatchedCommand.java

示例2: attemptUnsignFromMinusCommand

import org.apache.commons.lang3.ArrayUtils; //導入方法依賴的package包/類
private void attemptUnsignFromMinusCommand(GuildMessageReceivedEvent guildMessageReceivedEvent, String[] splitArguments) {
    final String numberOfPeopleArgument = splitArguments[0];
    final String[] gymArgument = ArrayUtils.removeAll(splitArguments, 0);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Trying to remove " + numberOfPeopleArgument + " from raid, gym " +
                StringUtils.join(gymArgument, " "));
    }
    final String guild = guildMessageReceivedEvent.getGuild().getName().trim().toLowerCase();
    final Config configForServer = serverConfigRepository.getConfigForServer(guild);
    final User user = guildMessageReceivedEvent.getAuthor();
    String message;
    try {
        message = raidRepository.executeUnsignCommand(configForServer, user,
                localeService.getLocaleForUser(user),
                splitArguments, "signup");
        guildMessageReceivedEvent.getMessage().addReaction(Emotes.OK).queue();
        ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
    } catch (Throwable t) {
        LOGGER.debug("Unsign command failed: " + t.getMessage());
        message = t.getMessage() + "\n\n" +
        "Syntax: *-1 Solna Platform*";
        guildMessageReceivedEvent.getMessage().addReaction(Emotes.ERROR).queue();
        ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
    }
    if (!StringUtils.isEmpty(message)) {
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(message);
        final String msgRemoveText =
                localeService.getMessageFor(LocaleService.KEEP_CHAT_CLEAN,
                        localeService.getLocaleForUser(user),
                        "15");
        embedBuilder.setFooter(msgRemoveText, null);
        guildMessageReceivedEvent.getMessage().getChannel().sendMessage(embedBuilder.build())
                .queue(msg -> {
                    msg.delete().queueAfter(15, TimeUnit.SECONDS); // Clean up feedback after x seconds
                }
        );
        LOGGER.debug("Removed signup.");
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:43,代碼來源:UnsignWithMinusCommandListener.java

示例3: attemptSignUpFromPlusCommand

import org.apache.commons.lang3.ArrayUtils; //導入方法依賴的package包/類
private void attemptSignUpFromPlusCommand(GuildMessageReceivedEvent guildMessageReceivedEvent, String[] splitArguments) {
    final String numberOfPeopleArgument = splitArguments[0];
    final String etaArgument = splitArguments[1];
    final String[] gymArgument = ArrayUtils.removeAll(splitArguments, 0, 1);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Trying to add " + numberOfPeopleArgument + " to raid, ETA " + etaArgument + " to gym " +
                StringUtils.join(gymArgument, " "));
    }
    final String guild = guildMessageReceivedEvent.getGuild().getName().trim().toLowerCase();
    final Config configForServer = serverConfigRepository.getConfigForServer(guild);
    final User user = guildMessageReceivedEvent.getAuthor();
    String message;
    try {
        message = raidRepository.executeSignUpCommand(configForServer, user,
                localeService.getLocaleForUser(user),
                splitArguments, "signup");
        guildMessageReceivedEvent.getMessage().addReaction(Emotes.OK).queue();
        ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
    } catch (Throwable t) {
        LOGGER.debug("Signup plus command failed: " + t.getMessage());
        message = t.getMessage() + "\n\n" +
        "Syntax: *+1 09:45 Solna Platform*";
        guildMessageReceivedEvent.getMessage().addReaction(Emotes.ERROR).queue();
        ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
    }
    if (!StringUtils.isEmpty(message)) {
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(message);
        final String msgRemoveText =
                localeService.getMessageFor(LocaleService.KEEP_CHAT_CLEAN,
                        localeService.getLocaleForUser(user), "15");
        embedBuilder.setFooter(msgRemoveText, null);
        guildMessageReceivedEvent.getMessage().getChannel().sendMessage(embedBuilder.build())
                .queue(msg -> {
                    msg.delete().queueAfter(15, TimeUnit.SECONDS); // Clean up feedback after x seconds
                }
        );
        LOGGER.debug("Added signup.");
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:43,代碼來源:SignupWithPlusCommandListener.java


注:本文中的org.apache.commons.lang3.ArrayUtils.removeAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。