本文整理汇总了Java中java.util.Collection.removeIf方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.removeIf方法的具体用法?Java Collection.removeIf怎么用?Java Collection.removeIf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collection
的用法示例。
在下文中一共展示了Collection.removeIf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import java.util.Collection; //导入方法依赖的package包/类
@Override
public Collection<Diff> apply(Object beforeObject, Object afterObject, String description) {
Collection<Diff> diffs = new ConcurrentLinkedQueue<>();
Map before = (Map) beforeObject;
Map after = (Map) afterObject;
if (isNullOrEmpty(before) && isNullOrEmpty(after)) {
diffs.add(new Diff.Builder().hasNotChanged().setFieldDescription(description).build());
} else if (!isNullOrEmpty(before) && isNullOrEmpty(after)) {
before.forEach((key, value) -> diffs.addAll(getDiffComputeEngine().evaluateAndExecute(value, null, description + "::" + key)));
} else if (isNullOrEmpty(before) && !isNullOrEmpty(after)) {
after.forEach((key, value) -> diffs.addAll(getDiffComputeEngine().evaluateAndExecute(null, value, description + "::" + key)));
} else {
before.forEach((key, value) -> diffs.addAll(getDiffComputeEngine().evaluateAndExecute(value, after.get(key), description + "::" + key)));
Collection<Diff> temp = new ConcurrentLinkedQueue<>();
//Now we need to ignore all besides DELETED items
after.forEach((key, value) -> temp.addAll(getDiffComputeEngine().evaluateAndExecute(before.get(key), value, description + "::" + key)));
temp.removeIf(delta -> delta.getChangeType().equals(ChangeType.NO_CHANGE) || delta.getChangeType().equals(ChangeType.UPDATED));
diffs.addAll(temp);
}
return diffs;
}
示例2: filterEventsByMultifactorAuthenticationProvider
import java.util.Collection; //导入方法依赖的package包/类
/**
* Filter events by multifactor authentication providers.
*
* @param resolveEvents the resolve events
* @param authentication the authentication
* @param registeredService the registered service
* @return the set of events
*/
protected Pair<Set<Event>, Collection<MultifactorAuthenticationProvider>> filterEventsByMultifactorAuthenticationProvider(
final Set<Event> resolveEvents, final Authentication authentication, final RegisteredService registeredService) {
LOGGER.debug("Locating multifactor providers to determine support for this authentication sequence");
final Map<String, MultifactorAuthenticationProvider> providers =
WebUtils.getAvailableMultifactorAuthenticationProviders(applicationContext);
if (providers == null || providers.isEmpty()) {
LOGGER.debug("No providers are available to honor this request. Moving on...");
return Pair.of(resolveEvents, Collections.emptySet());
}
final Collection<MultifactorAuthenticationProvider> flattenedProviders = flattenProviders(providers.values());
// remove providers that don't support the event
flattenedProviders.removeIf(p -> resolveEvents.stream().filter(e -> p.supports(e, authentication, registeredService)).count() == 0);
// remove events that are not supported by providers.
resolveEvents.removeIf(e -> flattenedProviders.stream().filter(p -> p.supports(e, authentication, registeredService)).count() == 0);
LOGGER.debug("Finalized set of resolved events are [{}]", resolveEvents);
return Pair.of(resolveEvents, flattenedProviders);
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:31,代码来源:SelectiveAuthenticationProviderWebflowEventEventResolver.java
示例3: addCompletions
import java.util.Collection; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
String prefix = result.getPrefixMatcher().getPrefix();
Collection<String> moduleNames
= FileBasedIndex.getInstance().getAllKeys(ModuleNameIndex.KEY, position.getProject());
moduleNames.removeIf(m -> !m.startsWith(prefix));
for (String moduleName : moduleNames) {
result.addElement(
LookupElementBuilder
.create(moduleName)
.withIcon(AllIcons.Modules.ModulesNode)
);
}
}
示例4: getReferencesByElement
import java.util.Collection; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (!(element instanceof XmlElement)) {
return PsiReference.EMPTY_ARRAY;
}
List<PsiReference> psiReferences = new ArrayList<>();
String methodName = StringUtil.unquoteString(element.getText());
PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) element);
if (phpClass != null) {
Collection<Method> methods = phpClass.getMethods();
methods.removeIf(m -> !m.getName().equalsIgnoreCase(methodName));
psiReferences.add(new PolyVariantReferenceBase(element, methods));
}
return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
示例5: getReferencesByElement
import java.util.Collection; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String parameterName = StringUtil.unquoteString(element.getText());
if (parameterName.isEmpty() || !(element instanceof XmlElement)) {
return PsiReference.EMPTY_ARRAY;
}
DiIndex diIndex = DiIndex.getInstance(element.getProject());
PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) element);
if (phpClass != null) {
Method constructor = phpClass.getConstructor();
if (constructor != null) {
Collection<Parameter> parameterList = new THashSet<>(Arrays.asList(constructor.getParameters()));
parameterList.removeIf(p -> !p.getName().contains(parameterName));
if (parameterList.size() > 0) {
return new PsiReference[] {new PolyVariantReferenceBase(element, parameterList)};
}
}
}
return PsiReference.EMPTY_ARRAY;
}
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:PhpConstructorArgumentReferenceProvider.java
示例6: apply
import java.util.Collection; //导入方法依赖的package包/类
@Override
public Collection<Diff> apply(final Object beforeObject, final Object afterObject, String description) {
Collection<Diff> diffs = new ConcurrentLinkedQueue<>();
Collection before = (Collection) beforeObject;
Collection after = (Collection) afterObject;
if (isNullOrEmpty(before) && isNullOrEmpty(after)) {
diffs.add(new Diff.Builder().hasNotChanged().setFieldDescription(description).build());
} else if (!isNullOrEmpty(before) && isNullOrEmpty(after)) {
before.parallelStream().forEach(object -> diffs.addAll(getDiffComputeEngine().evaluateAndExecute(object, null, description)));
} else if (isNullOrEmpty(before) && !isNullOrEmpty(after)) {
after.parallelStream().forEach(object -> diffs.addAll(getDiffComputeEngine().evaluateAndExecute(null, object, description)));
} else {
before.parallelStream().forEach(object ->
diffs.addAll(getDiffComputeEngine().evaluateAndExecute(object, ClassMetadataCache.getInstance().getCorrespondingObject(object, after), description)));
Collection<Diff> temp = new ConcurrentLinkedQueue<>();
//Now we need to ignore all Updated and Unchanged items
after.parallelStream().forEach(object ->
temp.addAll(getDiffComputeEngine().evaluateAndExecute(ClassMetadataCache.getInstance().getCorrespondingObject(object, before), object, description)));
if (!temp.isEmpty()) {
temp.removeIf(delta -> delta.getChangeType().equals(ChangeType.NO_CHANGE) || delta.getChangeType().equals(ChangeType.UPDATED));
diffs.addAll(temp);
}
}
return diffs;
}
示例7: apply
import java.util.Collection; //导入方法依赖的package包/类
@Override
public Collection<Diff> apply(final Object beforeObject, final Object afterObject, String description) {
Collection<Diff> diffs = new ConcurrentLinkedQueue<>();
Collection before = (Collection) beforeObject;
Collection after = (Collection) afterObject;
if (isNullOrEmpty(before) && isNullOrEmpty(after)) {
diffs.add(new Diff.Builder().hasNotChanged().setFieldDescription(description).build());
} else if (!isNullOrEmpty(before) && isNullOrEmpty(after)) {
before.parallelStream().forEach(object -> diffs.addAll(getDiffComputeEngine().evaluateAndExecute(object, null, description)));
} else if (isNullOrEmpty(before) && !isNullOrEmpty(after)) {
after.parallelStream().forEach(object -> diffs.addAll(getDiffComputeEngine().evaluateAndExecute(null, object, description)));
} else {
before.parallelStream().forEach(object ->
diffs.addAll(getDiffComputeEngine().evaluateAndExecute(object, findCorrespondingObject(object, after), description)));
Collection<Diff> temp = new ConcurrentLinkedQueue<>();
//Now we need to ignore all Updated and Unchanged items
after.parallelStream().forEach(object ->
temp.addAll(getDiffComputeEngine().evaluateAndExecute(findCorrespondingObject(object, before), object, description)));
if (!temp.isEmpty()) {
temp.removeIf(delta -> delta.getChangeType().equals(ChangeType.NO_CHANGE) || delta.getChangeType().equals(ChangeType.UPDATED));
diffs.addAll(temp);
}
}
return diffs;
}
示例8: collectPre3
import java.util.Collection; //导入方法依赖的package包/类
public static void collectPre3(){
Collection<String> c = new ArrayList<String>();
for (int i = 0; i < 10; i++) { // 加入0 ~ 9的字符串
c.add(String.valueOf(i));
}
c.removeIf(ele -> Integer.valueOf(ele) > 7);
c.forEach(ele -> System.out.print(ele + "\t"));
}
示例9: runRemoveif
import java.util.Collection; //导入方法依赖的package包/类
void runRemoveif (Collection<StringHolder> a, int atCounter) {
int startingSize = a.size();
a.removeIf((StringHolder t) -> t.getString().contains("@"));
assertTrue("removeIf removed " + (startingSize - a.size()) + " array elements, but was supposed to remove " + atCounter, (startingSize - a.size()) == atCounter);
Iterator<StringHolder> it1 = a.iterator();
while (it1.hasNext()) {
StringHolder i = it1.next();
assertFalse("removeIf has removed the wrong elements. Some of the elements intended for removal remain in the ArrayList.",i.getString().contains("@"));
}
}
示例10: getAllVirtualTypeElementNames
import java.util.Collection; //导入方法依赖的package包/类
public Collection<String> getAllVirtualTypeElementNames(PrefixMatcher prefixMatcher, final GlobalSearchScope scope) {
Collection<String> keys =
FileBasedIndex.getInstance().getAllKeys(VirtualTypeIndex.KEY, project);
keys.removeIf(k -> !prefixMatcher.prefixMatches(k));
return keys;
}
示例11: findAttributeValueElements
import java.util.Collection; //导入方法依赖的package包/类
public static Collection<XmlAttributeValue> findAttributeValueElements(XmlFile xmlFile,
String tagName,
String attributeName,
String value) {
Collection<XmlAttributeValue> psiElements = findAttributeValueElements(xmlFile, tagName, attributeName);
psiElements.removeIf(e -> e.getValue() == null || !e.getValue().equals(value));
return psiElements;
}
示例12: getReferencesByElement
import java.util.Collection; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
List<PsiReference> psiReferences = new ArrayList<>();
final Collection<PhpClassMember> members = new THashSet<>();
String origValue = element.getText();
String value = StringUtil.unquoteString(element.getText());
Matcher matcher = Pattern.compile(PhpRegex.Xml.CLASS_MEMBER_NAME).matcher(value);
if (!matcher.find()) {
return PsiReference.EMPTY_ARRAY;
}
String elementName = matcher.group(1);
String classFQN = value.substring(0, value.lastIndexOf("::"));
PhpIndex phpIndex = PhpIndex.getInstance(element.getProject());
for (final PhpClass phpClass : phpIndex.getAnyByFQN(classFQN)) {
members.addAll(phpClass.getFields());
members.addAll(phpClass.getMethods());
members.removeIf(c -> !c.getName().equals(elementName));
}
if (members.size() > 0) {
TextRange range = new TextRange(
origValue.indexOf(elementName),
origValue.indexOf(elementName) + elementName.length()
);
psiReferences.add(new PolyVariantReferenceBase(element, range, members));
}
return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
示例13: controleerAutorisatieVoorMutatielevering
import java.util.Collection; //导入方法依赖的package包/类
private void controleerAutorisatieVoorMutatielevering(final Autorisatiebundel autorisatiebundel) throws AutorisatieException {
final Leveringsautorisatie leveringsautorisatie = autorisatiebundel.getLeveringsautorisatie();
final Collection<Dienst> diensten = AutAutUtil.zoekDiensten(leveringsautorisatie, SoortDienst.MUTATIELEVERING_OP_BASIS_VAN_DOELBINDING,
SoortDienst.MUTATIELEVERING_OP_BASIS_VAN_AFNEMERINDICATIE);
// verwijder geblokkeerde en ongeldige diensten
diensten.removeIf(dienst -> !AutAutUtil.isGeldigEnNietGeblokkeerd(dienst, BrpNu.get().alsIntegerDatumNederland()));
if (diensten.isEmpty()) {
throw new AutorisatieException(new Melding(Regel.R1347));
}
}
示例14: demoRemoveIf
import java.util.Collection; //导入方法依赖的package包/类
private static void demoRemoveIf(Collection<String> collection) {
System.out.println("collection: " + collection);
System.out.println("Calling list.removeIf(e -> Two.equals(e))...");
collection.removeIf(e -> "Two".equals(e));
System.out.println("collection: " + collection);
}
示例15: addCompletions
import java.util.Collection; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
String prefix = result.getPrefixMatcher().getPrefix();
Matcher matcher = Pattern.compile(PHP_CLASS_COMPLETION_REGEX).matcher(prefix);
if (!matcher.matches()) {
return;
}
String className = prefix.lastIndexOf(92) < 0 ? prefix : prefix.substring(prefix.lastIndexOf(92) + 1);
String namespace = prefix.lastIndexOf(92) < 0 ? "" : prefix.substring(0, prefix.lastIndexOf(92));
PhpIndex phpIndex = PhpIndex.getInstance(parameters.getPosition().getProject());
final Collection<PhpClass> phpClasses = new THashSet<>();
Collection<String> namespaceNames = new ArrayList<>();
if (!className.isEmpty()) {
// case for input: "SomeClassOrNamespace"
// add classes
Collection<String> classNames = phpIndex.getAllClassNames(new CamelHumpMatcher(className));
for (String cName: classNames) {
phpClasses.addAll(phpIndex.getClassesByName(cName));
}
// add interfaces
Collection<String> interfaceNames = phpIndex.getAllInterfaceNames();
interfaceNames.removeIf(i -> !i.contains(className));
for (String iName: interfaceNames) {
phpClasses.addAll(phpIndex.getInterfacesByName(iName));
}
if (!namespace.isEmpty()) {
phpClasses.removeIf(c -> !c.getPresentableFQN().startsWith(namespace));
} else {
namespaceNames = phpIndex.getChildNamespacesByParentName("\\");
namespaceNames.removeIf(n -> !n.contains(prefix));
}
} else {
// case for input: "Some\Namespace\ + ^+<Space>"
// add namespaces
Collection<PhpNamespace> namespaces = phpIndex.getNamespacesByName(("\\" + namespace).toLowerCase());
for (PhpNamespace nsp: namespaces) {
phpClasses.addAll(PsiTreeUtil.getChildrenOfTypeAsList(nsp.getStatements(), PhpClass.class));
}
// add namespaces and classes (string representation)
namespaceNames
= phpIndex.getChildNamespacesByParentName("\\".concat(namespace).concat("\\").toLowerCase());
namespaceNames
= namespaceNames.stream().map(n -> namespace.concat("\\").concat(n)).collect(Collectors.toList());
}
// add all above founded items to lookup builder
// order is important (items with the same name override each other), add classes first
for (PhpClass phpClass : phpClasses) {
result.addElement(
LookupElementBuilder
.create(phpClass.getPresentableFQN())
.withIcon(phpClass.getIcon())
);
}
for (String nsName : namespaceNames) {
result.addElement(
LookupElementBuilder
.create(nsName)
.withIcon(PhpIcons.NAMESPACE)
);
}
}