下面列出了java.util.List#removeIf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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));
}
/**
* 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 );
}
}
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;
}
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));
}
}
/**
* @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);
}
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;
}
@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);
}
}
}
@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());
}
@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());
}
@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;
}
/**
* 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;
}
@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);
}
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;
}
private static List<Card> filterBySet(List<Card> collection, CardSet set) {
if (set == CardSet.ANY) {
return collection;
}
collection.removeIf(card -> card.getCardSet() != set);
return collection;
}
/**
* 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;
}
@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;
}
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));
}
/**
* 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;
}
/**
* Removes child anomalies
*/
private List<MergedAnomalyResultDTO> removeChildren(List<MergedAnomalyResultDTO> mergedAnomalies) {
mergedAnomalies.removeIf(MergedAnomalyResultBean::isChild);
return mergedAnomalies;
}
/**
* 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()));
}