Java Code Examples for org.apache.commons.lang3.ArrayUtils#remove()
The following examples show how to use
org.apache.commons.lang3.ArrayUtils#remove() .
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: LearnToClickPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event) { if ((event.getOption().equals("Floating <col=ff9040>World Map</col>") && config.shouldRightClickMap()) || (event.getTarget().equals("<col=ff9040>XP drops</col>") && config.shouldRightClickXp()) || (event.getOption().equals("Auto retaliate") && config.shouldRightClickRetaliate())) { forceRightClickFlag = true; } MenuEntry[] entries = client.getMenuEntries(); if (config.shouldBlockCompass()) { for (int i = entries.length - 1; i >= 0; i--) { if (entries[i].getOption().equals("Look North")) { entries = ArrayUtils.remove(entries, i); i--; } } client.setMenuEntries(entries); } }
Example 2
Source File: AbstractCli.java From incubator-iotdb with Apache License 2.0 | 6 votes |
static String[] processExecuteArgs(String[] args) { int index = -1; for (int i = 0; i < args.length; i++) { if (args[i].equals("-" + EXECUTE_ARGS)) { index = i; break; } } if (index >= 0 && ((index + 1 >= args.length) || (index + 1 < args.length && keywordSet .contains(args[index + 1])))) { return ArrayUtils.remove(args, index); } else if (index == -1) { return args; } else { StringBuilder executeCommand = new StringBuilder(); for (int j = index + 1; j < args.length; j++) { executeCommand.append(args[j]).append(" "); } executeCommand.deleteCharAt(executeCommand.length() - 1); execute = executeCommand.toString(); hasExecuteSQL = true; args = Arrays.copyOfRange(args, 0, index); return args; } }
Example 3
Source File: OverviewStatistics.java From geowave with Apache License 2.0 | 6 votes |
public boolean removeResolution(Resolution res) { synchronized (this) { int index = -1; for (int i = 0; i < resolutions.length; i++) { if (Arrays.equals( resolutions[i].getResolutionPerDimension(), res.getResolutionPerDimension())) { index = i; break; } } if (index >= 0) { resolutions = ArrayUtils.remove(resolutions, index); return true; } return false; } }
Example 4
Source File: AbstractNodePlaceholderResolver.java From JuniperBot with GNU General Public License v3.0 | 6 votes |
@Override public Object resolveNode(String placeholderName) { if (StringUtils.isEmpty(placeholderName)) { return getValue(); } String[] parts = placeholderName.split("\\."); String field = parts[0]; Object value = getChild(field); if (value instanceof NodePlaceholderResolver) { String subPlaceholder = null; if (parts.length > 1) { parts = ArrayUtils.remove(parts, 0); subPlaceholder = StringUtils.join(parts, "."); } return ((NodePlaceholderResolver) value).resolveNode(subPlaceholder); } return value; }
Example 5
Source File: CategoryManagerCacheWrapper.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void moveCategory(String categoryCode, String newParentCode) { Cache cache = this.getCache(); Category categoryNode1 = this.getCategory(categoryCode); Category categoryNode2 = this.getCategory(newParentCode); Category oldParent = this.getCategory(categoryNode1.getParentCode()); int index1 = Arrays.asList(oldParent.getChildrenCodes()).indexOf(categoryCode); String[] newChildren = ArrayUtils.remove(oldParent.getChildrenCodes(), index1); oldParent.setChildrenCodes(newChildren); cache.put(CATEGORY_CACHE_NAME_PREFIX + oldParent.getCode(), oldParent); String[] oldChildDest = categoryNode2.getChildrenCodes(); categoryNode1.setParentCode(categoryNode2.getCode()); cache.put(CATEGORY_CACHE_NAME_PREFIX + categoryNode1.getCode(), categoryNode1); String[] newChildren2 = ArrayUtils.add(oldChildDest, categoryNode1.getCode()); categoryNode2.setChildrenCodes(newChildren2); cache.put(CATEGORY_CACHE_NAME_PREFIX + categoryNode2.getCode(), categoryNode2); }
Example 6
Source File: AbstractCli.java From incubator-iotdb with Apache License 2.0 | 5 votes |
static String[] removePasswordArgs(String[] args) { int index = -1; for (int i = 0; i < args.length; i++) { if (args[i].equals("-" + PASSWORD_ARGS)) { index = i; break; } } if (index >= 0 && ((index + 1 >= args.length) || (index + 1 < args.length && keywordSet .contains(args[index + 1])))) { return ArrayUtils.remove(args, index); } return args; }
Example 7
Source File: ArrayUtilsUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenArray_whenRemovingElementAtSpecifiedPosition_thenCorrect() { int[] oldArray = { 1, 2, 3, 4, 5 }; int[] newArray = ArrayUtils.remove(oldArray, 1); int[] expectedArray = { 1, 3, 4, 5 }; assertArrayEquals(expectedArray, newArray); }
Example 8
Source File: GuiAphorismTile.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override protected void keyTyped(char par1, int par2){ if(par2 == 1) { NetworkHandler.sendToServer(new PacketAphorismTileUpdate(tile)); } else if(par2 == 200) { cursorY--; if(cursorY < 0) cursorY = textLines.length - 1; } else if(par2 == 208 || par2 == 156) { cursorY++; if(cursorY >= textLines.length) cursorY = 0; } else if(par2 == 28) { cursorY++; textLines = ArrayUtils.add(textLines, cursorY, ""); } else if(par2 == 14) { if(textLines[cursorY].length() > 0) { textLines[cursorY] = textLines[cursorY].substring(0, textLines[cursorY].length() - 1); } else if(textLines.length > 1) { textLines = ArrayUtils.remove(textLines, cursorY); cursorY--; if(cursorY < 0) cursorY = 0; } } else if(ChatAllowedCharacters.isAllowedCharacter(par1)) { textLines[cursorY] = textLines[cursorY] + par1; } tile.setTextLines(textLines); super.keyTyped(par1, par2); }
Example 9
Source File: ListRemoverAction.java From cs-actions with Apache License 2.0 | 5 votes |
/** * This method removes an element from a list of strings. * * @param list The list to remove from. * @param index The index of the element to remove from the list. * @param delimiter The list delimiter. * @return The new list. */ @Action(name = "List Remover", outputs = { @Output(RESPONSE), @Output(RETURN_RESULT), @Output(RETURN_CODE) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL), @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true) }) public Map<String, String> removeElement(@Param(value = LIST, required = true) String list, @Param(value = ELEMENT, required = true) String index, @Param(value = DELIMITER, required = true) String delimiter) { Map<String, String> result = new HashMap<>(); try { if (StringUtils.isEmpty(list) || StringUtils.isEmpty(index) || StringUtils.isEmpty(delimiter)) { throw new RuntimeException(EMPTY_INPUT_EXCEPTION); } else { String[] elements = StringUtils.split(list, delimiter); elements = ArrayUtils.remove(elements, Integer.parseInt(index)); result.put(RESPONSE, SUCCESS); result.put(RETURN_RESULT, StringUtils.join(elements, delimiter)); result.put(RETURN_CODE, RETURN_CODE_SUCCESS); } } catch (Exception e) { result.put(RESPONSE, FAILURE); result.put(RETURN_RESULT, e.getMessage()); result.put(RETURN_CODE, RETURN_CODE_FAILURE); } return result; }
Example 10
Source File: PageManagerCacheWrapper.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
private IPage updateOldParent(IPage pageToMove, boolean draft, Cache cache) { IPage oldParent = (draft) ? this.getDraftPage(pageToMove.getParentCode()) : this.getOnlinePage(pageToMove.getParentCode()); if (null == oldParent) { return null; } int index = Arrays.asList(oldParent.getChildrenCodes()).indexOf(pageToMove.getCode()); if (index > -1) { //rimuovo l'elemento dal vecchio parent String[] newChildren = ArrayUtils.remove(oldParent.getChildrenCodes(), index); ((Page) oldParent).setChildrenCodes(newChildren); cache.put(((draft) ? DRAFT_PAGE_CACHE_NAME_PREFIX : ONLINE_PAGE_CACHE_NAME_PREFIX) + oldParent.getCode(), oldParent); } return oldParent; }
Example 11
Source File: SettingsThemeFragment.java From Slide with GNU General Public License v3.0 | 5 votes |
public static ArrayAdapter<? extends CharSequence> createFromResource(@NonNull Context context, @ArrayRes int textArrayResId, @LayoutRes int layoutTypeResId) { CharSequence[] strings = context.getResources().getTextArray(textArrayResId); if (!Reddit.canUseNightModeAuto) { strings = ArrayUtils.remove(strings, SettingValues.NightModeState.AUTOMATIC.ordinal()); } return new ArrayAdapter<>(context, layoutTypeResId, Arrays.asList(strings)); }
Example 12
Source File: LoggingConfigurator.java From selenium-grid-extensions with Apache License 2.0 | 5 votes |
private static String[] clearLogFilenameParam(String[] args) { System.clearProperty(LOG_FILE_PROPERTY); int idx = Arrays.asList(args).indexOf(LOG_FILE_PARAM); if (-1 != idx) { if (args.length > idx + 1) args = ArrayUtils.remove(args, idx + 1); // value args = ArrayUtils.remove(args, idx); // name } return args; }
Example 13
Source File: AbstractFormattedFileCardExport.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
protected String[] splitLines(String content,boolean removeBlank) { String[] arr = UITools.stringLineSplit(content,removeBlank); if(skipFirstLine()) arr = ArrayUtils.remove(arr,0); return arr; }
Example 14
Source File: PythonRunner.java From mdw with Apache License 2.0 | 5 votes |
public Object exec(String script, Map<String,Object> values) throws ScriptException { // handle return statement String[] lines = script.split("\\r?\\n"); String returnExpr = null; for (int i = lines.length - 1; i >= 0; i--) { String line = lines[i].trim(); if (!line.isEmpty() && !line.startsWith("#")) { if (line.startsWith("return")) { returnExpr = line.substring(6).trim(); lines = ArrayUtils.remove(lines, i); script = String.join("\n", lines); } break; } } Bindings bindings = new SimpleBindings(values); scriptContext.setBindings(bindings, ScriptContext.ENGINE_SCOPE); ScriptEngine scriptEngine = getScriptEngine(); scriptEngine.eval(script, scriptContext); if (returnExpr != null) { return scriptEngine.eval(returnExpr, scriptContext); } else { return null; } }
Example 15
Source File: MacroCommand.java From ForgeHax with MIT License | 5 votes |
private void removeMacro(MacroEntry macro) { MACROS.remove(macro); if (macro.name.isPresent()) { MC.gameSettings.keyBindings = ArrayUtils.remove( MC.gameSettings.keyBindings, ArrayUtils.indexOf(MC.gameSettings.keyBindings, macro.getBind())); } // remove the category if there are no named macros to prevent crash // TODO: fix crash when a category is empty if (MACROS.stream().noneMatch(entry -> !entry.isAnonymous())) { KeyBinding.getKeybinds().remove("Macros"); } }
Example 16
Source File: L2MarketDataHelper.java From exchange-core with Apache License 2.0 | 4 votes |
public L2MarketDataHelper removeBid(int pos) { bidPrices = ArrayUtils.remove(bidPrices, pos); bidVolumes = ArrayUtils.remove(bidVolumes, pos); bidOrders = ArrayUtils.remove(bidOrders, pos); return this; }
Example 17
Source File: L2MarketDataHelper.java From exchange-core with Apache License 2.0 | 4 votes |
public L2MarketDataHelper removeAsk(int pos) { askPrices = ArrayUtils.remove(askPrices, pos); askVolumes = ArrayUtils.remove(askVolumes, pos); askOrders = ArrayUtils.remove(askOrders, pos); return this; }
Example 18
Source File: RemoveElementFromAnArray.java From tutorials with MIT License | 4 votes |
public int[] removeAnElementWithAGivenIndex(int[] array, int index) { return ArrayUtils.remove(array, index); }
Example 19
Source File: CodeGenUtils.java From sailfish-core with Apache License 2.0 | 4 votes |
public static String getPackage(IFieldStructure fieldStructure, String[] packageName, boolean underscoreAsPackageSeparator) { String[] classPath = getClassPath(fieldStructure, packageName, true, underscoreAsPackageSeparator); classPath = ArrayUtils.remove(classPath, classPath.length - 1); return String.join(".", classPath); }
Example 20
Source File: ConstraintContext.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
public ConstraintContext withoutMessage(int index) { return new ConstraintContext((String[]) ArrayUtils.remove(messageArgs,index)); }