Java Code Examples for java.util.List#removeIf()
The following examples show how to use
java.util.List#removeIf() .
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: Objects.java From jolt with Apache License 2.0 | 6 votes |
/** * Squashes nulls in a list or map. * * Modifies the data. */ public static void squashNulls( Object input ) { if ( input instanceof List ) { List inputList = (List) input; inputList.removeIf( java.util.Objects::isNull ); } else if ( input instanceof Map ) { Map<String,Object> inputMap = (Map<String,Object>) input; List<String> keysToNuke = new ArrayList<>(); for (Map.Entry<String,Object> entry : inputMap.entrySet()) { if ( entry.getValue() == null ) { keysToNuke.add( entry.getKey() ); } } inputMap.keySet().removeAll( keysToNuke ); } }
Example 2
Source File: GroundItemsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
void updateList(String item, boolean hiddenList) { final List<String> hiddenItemSet = new ArrayList<>(hiddenItemList); final List<String> highlightedItemSet = new ArrayList<>(highlightedItemsList); if (hiddenList) { highlightedItemSet.removeIf(item::equalsIgnoreCase); } else { hiddenItemSet.removeIf(item::equalsIgnoreCase); } final List<String> items = hiddenList ? hiddenItemSet : highlightedItemSet; if (!items.removeIf(item::equalsIgnoreCase)) { items.add(item); } config.setHiddenItems(Text.toCSV(hiddenItemSet)); config.setHighlightedItem(Text.toCSV(highlightedItemSet)); }
Example 3
Source File: ConfigHandler.java From ClusterDeviceControlPlatform with MIT License | 6 votes |
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { super.channelActive(ctx); logger.info("通道重置"); List<ChannelPipeline> channelPipelines = tcpMediator.getSendingMsgRepo().getChannelPipelines(); channelPipelines.add(ctx.pipeline()); channelPipelines.removeIf(channel -> { i++; if (channel == null || !channel.channel().isActive()) { logger.info("「" + i + "」" + "通道失效"); return true; } else { logger.info("「" + i + "」" + "通道有效"); return false; } }); i = 0; logger.info("通道数量:" + channelPipelines.size()); }
Example 4
Source File: FluidRecipeJEI.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void getIngredients(@Nonnull IIngredients ingredients) { List<List<ItemStack>> stacks = Lists.newArrayList(); stacks.add(Lists.newArrayList(builder.getMainInput().getMatchingStacks())); for (Ingredient ingredient : builder.getInputs()) stacks.add(Lists.newArrayList(ingredient.getMatchingStacks())); if (!isFluidOutput()) for (List<ItemStack> stackList : stacks) stackList.removeIf(Ingredient.fromStacks(builder.getOutput())::apply); ingredients.setInputLists(ItemStack.class, stacks); ingredients.setInput(FluidStack.class, new FluidStack(builder.getFluid(), 1000)); if (isFluidOutput()) ingredients.setOutput(FluidStack.class, builder.getFluidOutput()); else ingredients.setOutput(ItemStack.class, builder.getOutput()); }
Example 5
Source File: JadxUpdate.java From jadx with Apache License 2.0 | 6 votes |
private static Release checkForNewRelease() throws IOException { String version = JadxDecompiler.getVersion(); if (version.contains("dev")) { LOG.debug("Ignore check for update: development version"); return null; } List<Release> list = get(GITHUB_RELEASES_URL, RELEASES_LIST_TYPE); if (list == null) { return null; } list.removeIf(release -> release.getName().equalsIgnoreCase(version) || release.isPreRelease()); if (list.isEmpty()) { return null; } list.sort(RELEASE_COMPARATOR); Release latest = list.get(list.size() - 1); if (VersionComparator.checkAndCompare(version, latest.getName()) >= 0) { return null; } LOG.info("Found new jadx version: {}", latest); return latest; }
Example 6
Source File: MailActivityBehavior.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void getFilesFromFields(Expression expression, PlanItemInstanceEntity planItemInstanceEntity, List<File> files, List<DataSource> dataSources) { if (expression == null) { return; } Object value = expression.getValue(planItemInstanceEntity); if (value != null) { if (value instanceof Collection) { Collection collection = (Collection) value; if (!collection.isEmpty()) { for (Object object : collection) { addExpressionValueToAttachments(object, files, dataSources); } } } else { addExpressionValueToAttachments(value, files, dataSources); } files.removeIf(file -> !fileExists(file)); } }
Example 7
Source File: Capability_impl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * @see org.apache.uima.resource.metadata.Capability#setLanguagesSupported(String[]) */ public void setLanguagesSupported(String[] aLanguageIDs) { // create a list of existing preconditions List<Precondition> preconditions = new ArrayList<>(); Precondition[] precondArray = getPreconditions(); if (precondArray != null) { preconditions.addAll(Arrays.asList(precondArray)); } // remove any existing LanguagePrecondtiions preconditions.removeIf(p -> p instanceof LanguagePrecondition); // add new precondition if (aLanguageIDs != null && aLanguageIDs.length > 0) { LanguagePrecondition languagePrecond = new LanguagePrecondition_impl(); languagePrecond.setLanguages(aLanguageIDs); preconditions.add(languagePrecond); } // set attribute value Precondition[] newPrecondArray = new Precondition[preconditions.size()]; preconditions.toArray(newPrecondArray); setPreconditions(newPrecondArray); }
Example 8
Source File: ListDefaults.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test public void testRemoveIfThrowsCME() { @SuppressWarnings("unchecked") final CollectionSupplier<List<Integer>> supplier = new CollectionSupplier(LIST_CME_SUPPLIERS, SIZE); for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) { final List<Integer> list = test.collection; if (list.size() <= 1) { continue; } boolean gotException = false; try { // bad predicate that modifies its list, should throw CME list.removeIf(list::add); } catch (ConcurrentModificationException cme) { gotException = true; } if (!gotException) { fail("expected CME was not thrown from " + test); } } }
Example 9
Source File: GuiceBindingsRenderer.java From dropwizard-guicey with MIT License | 6 votes |
private List<ModuleDeclaration> filter(final List<ModuleDeclaration> modules, final GuiceConfig config) { modules.removeIf(it -> config.getIgnoreModules().contains(it.getType()) || (!it.isJITBindings() && filter(it.getType().getName(), config.getIgnorePackages()))); for (ModuleDeclaration mod : modules) { if (modulesDisabled.contains(mod.getType())) { // ignore removed module's subtree mod.getDeclarations().clear(); mod.getMarkers().add(REMOVED); mod.getChildren().clear(); } else { mod.getDeclarations().removeIf(it -> it.getKey() != null && filter( it.getKey().getTypeLiteral().getRawType().getName(), config.getIgnorePackages())); } filter(mod.getChildren(), config); } return modules; }
Example 10
Source File: Protocol_1_10.java From multiconnect with MIT License | 5 votes |
@Override public List<RecipeInfo<?>> getCraftingRecipes() { List<RecipeInfo<?>> recipes = super.getCraftingRecipes(); recipes.removeIf(recipe -> recipe.getOutput().getItem() instanceof BlockItem && ((BlockItem) recipe.getOutput().getItem()).getBlock() instanceof ShulkerBoxBlock); recipes.removeIf(recipe -> recipe.getOutput().getItem() == Items.OBSERVER); return recipes; }
Example 11
Source File: GeometryUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Query and test intersection on the result of an STRtree index containing geometries. * * @param tree the index. * @param intersectionGeometry the geometry to check; * @return the intersecting geometries. */ public static List<Geometry> queryAndIntersectGeometryTree( STRtree tree, Geometry intersectionGeometry ) { @SuppressWarnings("unchecked") List<Geometry> result = tree.query(intersectionGeometry.getEnvelopeInternal()); result.removeIf(item -> { Geometry g = (Geometry) item; if (g.intersects(intersectionGeometry)) { return false; } return true; }); return result; }
Example 12
Source File: FilterCardsCommand.java From metastone with GNU General Public License v2.0 | 5 votes |
private static List<Card> filterBySet(List<Card> collection, CardSet set) { if (set == CardSet.ANY) { return collection; } collection.removeIf(card -> card.getCardSet() != set); return collection; }
Example 13
Source File: InstanceValidatorTest.java From vespa with Apache License 2.0 | 5 votes |
private List<Node> allocateNode(List<Node> nodeList, Node node, ApplicationId applicationId) { nodeList.removeIf(n -> n.id().equals(node.id())); nodeList.add(node.allocate(applicationId, ClusterMembership.from("container/default/0/0", Version.fromString("6.123.4"), Optional.empty()), new NodeResources(1, 1, 1, 1), Instant.now())); return nodeList; }
Example 14
Source File: MailConnectionGUI.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public List<ConnectionParameterModel> getInjectableParameters(ConnectionParameterGroupModel group) { List<ConnectionParameterModel> mainParameters = super.getInjectableParameters(group); List<ConnectionParameterModel> injectableParameters = new ArrayList<>(); if (handler == SEND) { ConnectionParameterGroupModel mailGroupModel = connectionModel.getParameterGroup(GROUP_MAIL); ConnectionParameterGroupModel sendmailGroupModel = connectionModel.getParameterGroup(GROUP_SENDMAIL); injectableParameters.addAll(super.getInjectableParameters(mailGroupModel)); injectableParameters.addAll(super.getInjectableParameters(sendmailGroupModel)); } injectableParameters.addAll(mainParameters); injectableParameters.removeIf(p -> !p.isEnabled()); return Collections.unmodifiableList(injectableParameters); }
Example 15
Source File: Main.java From diff-check with GNU Lesser General Public License v2.1 | 5 votes |
/** * Determines all the files, that should be analyzed by PMD. * @param configuration contains either the file path or the DB URI, from where to load the files * @param languages used to filter by file extension * @return List<DataSource> of files */ public static List<DataSource> getApplicableFiles(PMDConfiguration configuration, Set<Language> languages) { long startFiles = System.nanoTime(); List<DataSource> files = internalGetApplicableFiles(configuration, languages); if (StringUtils.isNotBlank(configuration.getExcludeRegexp())) { Pattern excludePattern = Pattern.compile(configuration.getExcludeRegexp()); files.removeIf(file -> excludePattern.matcher(file.getNiceFileName(false, "")).matches()); } long endFiles = System.nanoTime(); Benchmarker.mark(Benchmark.CollectFiles, endFiles - startFiles, 0); return files; }
Example 16
Source File: DefaultConfigPreHook.java From drftpd with GNU General Public License v2.0 | 5 votes |
@CommandHook(commands = {"doBW", "doIdlers", "doLeechers", "doSITE_SWHO", "doSITE_WHO", "doSpeed", "doUploaders"}, priority = 2, type = HookType.PRE) public CommandRequestInterface hideInWhoHook(CommandRequest request) { List<BaseFtpConnection> conns = Master.getConnectionManager().getConnections(); ConfigInterface cfg = GlobalContext.getConfig(); conns.removeIf(conn -> cfg.checkPathPermission("hideinwho", conn.getUserNull(), conn.getCurrentDirectory())); request.getSession().setObject(UserManagementHandler.CONNECTIONS, conns); return request; }
Example 17
Source File: CuratorDatabaseClient.java From vespa with Apache License 2.0 | 4 votes |
/** * Returns all nodes allocated to the given application which are in one of the given states * If no states are given this returns all nodes. */ public List<Node> readNodes(ApplicationId applicationId, Node.State ... states) { List<Node> nodes = readNodes(states); nodes.removeIf(node -> ! node.allocation().isPresent() || ! node.allocation().get().owner().equals(applicationId)); return nodes; }
Example 18
Source File: CodeClimateConfigTest.java From AuthMeReloaded with GNU General Public License v3.0 | 4 votes |
private static void removeTestsExclusionOrThrow(List<String> excludePaths) { boolean wasRemoved = excludePaths.removeIf("src/test/java/**/*Test.java"::equals); assertThat("Expected an exclusion for test classes", wasRemoved, equalTo(true)); }
Example 19
Source File: AnomaliesResource.java From incubator-pinot with Apache License 2.0 | 4 votes |
/** * Removes child anomalies */ private List<MergedAnomalyResultDTO> removeChildren(List<MergedAnomalyResultDTO> mergedAnomalies) { mergedAnomalies.removeIf(MergedAnomalyResultBean::isChild); return mergedAnomalies; }
Example 20
Source File: ClusterCachesInfo.java From ignite with Apache License 2.0 | 4 votes |
/** * Filters from local join context cache descriptors that should be started on join. * * @param locJoinStartCaches Collection to filter. */ private void filterLocalJoinStartCaches( List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> locJoinStartCaches) { locJoinStartCaches.removeIf(next -> !registeredCaches.containsKey(next.getKey().cacheName())); }