List of usage examples for java.util Set removeAll
boolean removeAll(Collection<?> c);
From source file:com.espertech.esper.rowregex.EventRowRegexHelper.java
/** * Inspect variables recursively./* w w w . ja va 2 s . c o m*/ * @param parent parent regex expression node * @param isMultiple if the variable in the stack is multiple of single * @param variablesSingle single variables list * @param variablesMultiple group variables list */ protected static void recursiveInspectVariables(RowRegexExprNode parent, boolean isMultiple, Set<String> variablesSingle, Set<String> variablesMultiple) { if (parent instanceof RowRegexExprNodeNested) { RowRegexExprNodeNested nested = (RowRegexExprNodeNested) parent; for (RowRegexExprNode child : parent.getChildNodes()) { recursiveInspectVariables(child, nested.getType().isMultipleMatches() || isMultiple, variablesSingle, variablesMultiple); } } else if (parent instanceof RowRegexExprNodeAlteration) { for (RowRegexExprNode childAlteration : parent.getChildNodes()) { LinkedHashSet<String> singles = new LinkedHashSet<String>(); LinkedHashSet<String> multiples = new LinkedHashSet<String>(); recursiveInspectVariables(childAlteration, isMultiple, singles, multiples); variablesMultiple.addAll(multiples); variablesSingle.addAll(singles); } variablesSingle.removeAll(variablesMultiple); } else if (parent instanceof RowRegexExprNodeAtom) { RowRegexExprNodeAtom atom = (RowRegexExprNodeAtom) parent; String name = atom.getTag(); if (variablesMultiple.contains(name)) { return; } if (variablesSingle.contains(name)) { variablesSingle.remove(name); variablesMultiple.add(name); return; } if (atom.getType().isMultipleMatches()) { variablesMultiple.add(name); return; } if (isMultiple) { variablesMultiple.add(name); } else { variablesSingle.add(name); } } else { for (RowRegexExprNode child : parent.getChildNodes()) { recursiveInspectVariables(child, isMultiple, variablesSingle, variablesMultiple); } } }
From source file:com.linuxbox.enkive.workspace.searchFolder.SearchFolder.java
public void removeMessageIds(Collection<String> messageIds) throws WorkspaceException { for (SearchFolderSearchResult result : results) { Set<String> folderMessageIds = result.getMessageIds(); if (folderMessageIds.removeAll(messageIds)) { if (folderMessageIds.isEmpty()) { result.deleteSearchResult(); results.remove(result);// w ww .j av a 2 s .co m } else { result.setMessageIds(folderMessageIds); result.saveSearchResult(); } } } }
From source file:eu.dime.ps.semantic.query.impl.AbstractQuery.java
/** * Retrieves a resource from the knowledge base or model set provided. * /*from w w w .j a v a2 s . co m*/ * @param resource * @return * @throws NotFoundException */ protected T get(org.ontoware.rdf2go.model.node.Resource resource) throws NotFoundException { if (selectedProperties != null && selectedProperties.length > 0 && discardedProperties != null && discardedProperties.length > 0) { Set<URI> properties = new HashSet<URI>(); properties.addAll(Arrays.asList(selectedProperties)); properties.removeAll(Arrays.asList(discardedProperties)); return rdfStore.get(resource, returnType, properties.toArray(new URI[properties.size()])); } else if (selectedProperties != null && selectedProperties.length > 0) { return rdfStore.get(resource, returnType, selectedProperties); // } else if (discardedProperties != null && discardedProperties.length > 0) { // return rdfStore.get(resource, returnType, true, discardedProperties); } else { return rdfStore.get(resource, returnType); } }
From source file:io.cloudslang.lang.compiler.modeller.transformers.SeqStepsTransformer.java
private void validateOnlySupportedKeys(Map<String, String> tMap, Set<String> mandatoryKeys, Set<String> optionalKeys) { Set<String> invalidKeys = new HashSet<>(tMap.keySet()); invalidKeys.removeAll(mandatoryKeys); invalidKeys.removeAll(optionalKeys); if (isNotEmpty(invalidKeys)) { throw new RuntimeException( SEQ_OPERATION_ILLEGAL_TAGS + invalidKeys.toString() + INVALID_KEYS_ERROR_MESSAGE_SUFFIX); }//from ww w . j a va 2 s. co m }
From source file:com.github.fge.jsonschema.core.keyword.syntax.SyntaxProcessor.java
private void validate(final ProcessingReport report, final SchemaTree tree) throws ProcessingException { final JsonNode node = tree.getNode(); final NodeType type = NodeType.getNodeType(node); /*//from ww w . java2 s .c om * Barf if not an object, and don't even try to go any further */ if (type != NodeType.OBJECT) { report.error(newMsg(tree, "core.notASchema").putArgument("found", type)); return; } /* * Grab all checkers and object member names. Retain in checkers only * existing keywords, and remove from the member names set what is in * the checkers' key set: if non empty, some keywords are missing, * report them. */ final Map<String, SyntaxChecker> map = Maps.newTreeMap(); map.putAll(checkers); final Set<String> fields = Sets.newHashSet(node.fieldNames()); map.keySet().retainAll(fields); fields.removeAll(map.keySet()); if (!fields.isEmpty()) report.warn(newMsg(tree, "core.unknownKeywords").putArgument("ignored", Ordering.natural().sortedCopy(fields))); /* * Now, check syntax of each keyword, and collect pointers for further * analysis. */ final List<JsonPointer> pointers = Lists.newArrayList(); for (final SyntaxChecker checker : map.values()) checker.checkSyntax(pointers, bundle, report, tree); /* * Operate on these pointers. */ for (final JsonPointer pointer : pointers) validate(report, tree.append(pointer)); }
From source file:com.github.fge.jsonschema.syntax.SyntaxProcessor.java
private void validate(final ProcessingReport report, final SchemaTree tree) throws ProcessingException { final JsonNode node = tree.getNode(); final NodeType type = NodeType.getNodeType(node); /*//w ww. ja v a2 s. co m * Barf if not an object, and don't even try to go any further */ if (type != NodeType.OBJECT) { final ProcessingMessage msg = newMsg(tree).message(BUNDLE.getString("notASchema")).put("found", type); report.error(msg); return; } /* * Grab all checkers and object member names. Retain in checkers only * existing keywords, and remove from the member names set what is in * the checkers' key set: if non empty, some keywords are missing, * report them. */ final Map<String, SyntaxChecker> map = Maps.newTreeMap(); map.putAll(checkers); final Set<String> fieldNames = Sets.newHashSet(node.fieldNames()); map.keySet().retainAll(fieldNames); fieldNames.removeAll(map.keySet()); if (!fieldNames.isEmpty()) report.warn(newMsg(tree).message(BUNDLE.getString("unknownKeywords")).put("ignored", Ordering.natural().sortedCopy(fieldNames))); /* * Now, check syntax of each keyword, and collect pointers for further * analysis. */ final List<JsonPointer> pointers = Lists.newArrayList(); for (final SyntaxChecker checker : map.values()) checker.checkSyntax(pointers, report, tree); /* * Operate on these pointers. */ for (final JsonPointer pointer : pointers) validate(report, tree.append(pointer)); }
From source file:com.clicktravel.cheddar.server.application.lifecycle.LifecycleController.java
private Set<MessageListener> messageListenersExcept(final MessageListener... exceptions) { final Set<MessageListener> result = new HashSet<>(messageListeners); result.removeAll(Arrays.asList(exceptions)); return result; }
From source file:org.jasig.portlet.contacts.control.PortletEditController.java
@ModelAttribute("domains") public DomainMap getDomains(PortletPreferences prefs) { final List<String> domainActive = Arrays.asList(prefs.getValues("domainsActive", new String[0])); String[] defaultOn = prefs.getValues("defaultOn", new String[0]); String[] userOn = prefs.getValues("domainOn", new String[0]); String[] userOff = prefs.getValues("domainOff", new String[0]); Set<String> domains = new HashSet<String>(); domains.addAll(Arrays.asList(defaultOn)); domains.addAll(Arrays.asList(userOn)); domains.removeAll(Arrays.asList(userOff)); Map<String, Boolean> domainsMap = new TreeMap<String, Boolean>(); for (String domain : domainActive) { domainsMap.put(domain, domains.contains(domain)); }/* w w w . j av a 2s . c om*/ return new DomainMap(domainsMap); }
From source file:de.interactive_instruments.ShapeChange.Transformation.Profiling.ProfileIdentifierMap.java
/** * @param other, shall not be <code>null</code> * @param messages/*from w w w. ja v a 2 s.c om*/ * List to store the reason(s) why this map does not contain the * other map; can be null * @return */ public boolean contains(ProfileIdentifierMap other, List<String> messages) { // identify which profiles from the other map are not contained in // this map Set<String> difference = new HashSet<String>(other.getProfileIdentifiersByName().keySet()); difference.removeAll(profileIdentifiersByName.keySet()); if (!difference.isEmpty()) { // we found identifiers in the other map that are not contained in // this map if (messages != null) { String s = StringUtils.join(difference, " "); messages.add("The profile set owned by '" + this.getOwnerName() + "' does not contain the following profiles owned by '" + other.getOwnerName() + "': " + s); } return false; } boolean result = true; // Now that we know that at least the names of the other profile // identifiers are contained in this map, also ensure that the // versions stated for other identifiers are contained in the // identifiers of this map. for (String key : other.getProfileIdentifiersByName().keySet()) { ProfileIdentifier pIdThis = this.profileIdentifiersByName.get(key); ProfileIdentifier pIdOther = other.getProfileIdentifiersByName().get(key); if (!pIdThis.contains(pIdOther, messages)) { result = false; // we do not break here to identify and log all possible issues // with the identifiers } } return result; }
From source file:cc.kave.commons.model.groum.SubGroum.java
private Set<Node> getAllNodesReachableInOneHop() { Set<Node> neighborNodes = new HashSet<>(); for (Node node : nodes) { neighborNodes.addAll(parent.getSuccessors(node)); }/*from w w w .j a v a2 s .co m*/ neighborNodes.removeAll(nodes); return neighborNodes; }