List of usage examples for java.util HashSet addAll
boolean addAll(Collection<? extends E> c);
From source file:org.alfresco.repo.security.authentication.AbstractChainingAuthenticationService.java
/** * {@inheritDoc}//from w w w . j a v a2 s .c om */ public Set<String> getDomainsThatAllowUserDeletion() { HashSet<String> domains = new HashSet<String>(); if (getMutableAuthenticationService() != null) { domains.addAll(getMutableAuthenticationService().getDomainsThatAllowUserDeletion()); } return domains; }
From source file:org.alfresco.repo.security.authentication.AbstractChainingAuthenticationService.java
/** * {@inheritDoc}/*from w w w .j ava2s . c o m*/ */ public Set<String> getDomiansThatAllowUserPasswordChanges() { HashSet<String> domains = new HashSet<String>(); if (getMutableAuthenticationService() != null) { domains.addAll(getMutableAuthenticationService().getDomiansThatAllowUserPasswordChanges()); } return domains; }
From source file:io.seldon.api.state.ZkSubscriptionHandler.java
private Collection<ChildData> getChildren(String node, TreeCache cache) { HashSet<ChildData> toReturn = new HashSet<>(); if (cache == null) { cache = findParentCache(node);/*ww w . j a v a 2 s .co m*/ if (cache == null) return Collections.EMPTY_LIST; } Map<String, ChildData> children = cache.getCurrentChildren(node); if (children == null) return toReturn; for (ChildData child : children.values()) toReturn.addAll(getChildren(child.getPath(), cache)); toReturn.addAll(children.values()); return toReturn; }
From source file:edu.northwestern.chip.banner.banner.tagging.dictionary.DictionaryTagger.java
public boolean add(List<String> tokens, Collection<EntityType> types) { if (tokens.size() == 0) throw new IllegalArgumentException("Number of tokens must be greater than zero"); // Verify that the sequence to be added is not listed as not included Boolean value = notInclude.getValue(tokens); if (value != null) return false; // If configured, drop parenthetical phrases at the end of the sequence if (dropEndParentheticals && tokens.get(tokens.size() - 1).equals(")")) { int openParen = tokens.size() - 1; while (openParen > 0 && !tokens.get(openParen).equals("(")) openParen--;/*from w w w . j a v a2s .c om*/ if (openParen <= 0) return false; tokens = tokens.subList(0, openParen); } HashSet<EntityType> currentTypes = entities.getValue(tokens); if (currentTypes == null) { currentTypes = new HashSet<EntityType>(1); entities.add(tokens, currentTypes); } return currentTypes.addAll(types); }
From source file:org.jactr.core.module.declarative.search.local.DefaultSearchSystem.java
/** * this implementation fails fast//from w w w . java2 s . c o m * * @see org.jactr.core.module.declarative.search.ISearchSystem#findExact(ChunkTypeRequest, * java.util.Comparator) */ public Collection<IChunk> findExact(ChunkTypeRequest pattern, Comparator<IChunk> sortRule) { /* * second pass, ditch all those that don't match our chunktype */ HashSet<IChunk> candidates = new HashSet<IChunk>(); IChunkType chunkType = pattern.getChunkType(); if (chunkType != null) candidates.addAll(chunkType.getSymbolicChunkType().getChunks()); /* * first things first, find all the candidates based on the content of the * pattern */ boolean first = chunkType == null; for (IConditionalSlot slot : pattern.getConditionalSlots()) { if (first) { candidates.addAll(find(slot)); first = false; } else candidates.retainAll(find(slot)); if (candidates.size() == 0) break; } if (LOGGER.isDebugEnabled()) LOGGER.debug("First pass candidates for " + pattern + " chunks: " + candidates); if (sortRule != null) { /* * finally, we sort them */ TreeSet<IChunk> sortedResults = new TreeSet<IChunk>(sortRule); sortedResults.addAll(candidates); return sortedResults; } return candidates; }
From source file:com.d2dx.j2objc.TranslateMojo.java
public void execute() throws MojoExecutionException, MojoFailureException { if (this.includeDependencySources) { //@formatter:off executeMojo(/*from ww w . ja va2 s . c o m*/ plugin(groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.8")), goal("unpack-dependencies"), configuration(element("classifier", "sources"), element("failOnMissingClassifierArtifact", "false"), element(name("outputDirectory"), "${project.build.directory}/j2objc-sources")), executionEnvironment(this.mavenProject, this.mavenSession, this.pluginManager)); } /* * Extracts j2objc automagically */ //@formatter:off executeMojo( plugin(groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.8")), goal("unpack"), configuration( element("artifactItems", element("artifactItem", element("groupId", "com.d2dx.j2objc"), element("artifactId", "j2objc-package"), element("version", this.j2objcVersion))), element(name("outputDirectory"), "${project.build.directory}/j2objc-bin")), executionEnvironment(this.mavenProject, this.mavenSession, this.pluginManager)); //@formatter:on /* * Time to do detection and run j2objc with proper parameters. */ this.outputDirectory.mkdirs(); // Gather the source paths // Right now, we limit to sources in two directories: project srcdir, and additional sources. // Later, we should add more. HashSet<String> srcPaths = new HashSet<String>(); String srcDir = this.mavenSession.getCurrentProject().getBuild().getSourceDirectory(); srcPaths.add(srcDir); String buildDir = this.mavenSession.getCurrentProject().getBuild().getDirectory(); String addtlSrcDir = buildDir + "/j2objc-sources"; srcPaths.add(addtlSrcDir); // Gather sources. HashSet<File> srcFiles = new HashSet<File>(); for (String path : srcPaths) { File sdFile = new File(path); Collection<File> scanFiles = FileUtils.listFiles(sdFile, new String[] { "java" }, true); srcFiles.addAll(scanFiles); } // Gather prefixes into a file FileOutputStream fos; OutputStreamWriter out; if (this.prefixes != null) { try { fos = new FileOutputStream(new File(this.outputDirectory, "prefixes.properties")); out = new OutputStreamWriter(fos); for (Prefix p : this.prefixes) { out.write(p.javaPrefix); out.write(": "); out.write(p.objcPrefix); out.write("\n"); } out.flush(); out.close(); fos.close(); } catch (FileNotFoundException e) { throw new MojoExecutionException("Could not create prefixes file"); } catch (IOException e1) { throw new MojoExecutionException("Could not create prefixes file"); } } // We now have: // Sources, source directories, and prefixes. // Call the maven-exec-plugin with the new environment! LinkedList<Element> args = new LinkedList<Element>(); if (this.includeClasspath) { args.add(new Element("argument", "-cp")); args.add(new Element("classpath", "")); } String srcDirsArgument = ""; for (String p : srcPaths) srcDirsArgument += ":" + p; // Crop the first colon if (srcDirsArgument.length() > 0) srcDirsArgument = srcDirsArgument.substring(1); args.add(new Element("argument", "-sourcepath")); args.add(new Element("argument", srcDirsArgument)); if (this.prefixes != null) { args.add(new Element("argument", "--prefixes")); args.add(new Element("argument", this.outputDirectory.getAbsolutePath() + "/prefixes.properties")); } args.add(new Element("argument", "-d")); args.add(new Element("argument", this.outputDirectory.getAbsolutePath())); for (File f : srcFiles) args.add(new Element("argument", f.getAbsolutePath())); try { Runtime.getRuntime() .exec("chmod u+x " + this.mavenProject.getBuild().getDirectory() + "/j2objc-bin/j2objc"); } catch (IOException e) { e.printStackTrace(); } //@formatter:off executeMojo(plugin(groupId("org.codehaus.mojo"), artifactId("exec-maven-plugin"), version("1.3")), goal("exec"), configuration(element("arguments", args.toArray(new Element[0])), element("executable", this.mavenProject.getBuild().getDirectory() + "/j2objc-bin/j2objc"), element("workingDirectory", this.mavenProject.getBuild().getDirectory() + "/j2objc-bin/")), executionEnvironment(this.mavenProject, this.mavenSession, this.pluginManager)); //@formatter:on }
From source file:com.activecq.samples.workflow.impl.TagExplosionProcessWorkflow.java
/** * Returns localized Tag Titles for all the ancestor tags to the tags supplied in "tagPaths" * <p/>//from ww w . j a va 2 s . c om * Tags in * * @param tags * @param explodedTags * @return */ private HashSet<String> getExplodedTags(final List<Tag> tags, HashSet<String> explodedTags) { for (final Tag tag : tags) { explodedTags.add(tag.getTagID()); if (tag.listChildren() != null && tag.listChildren().hasNext()) { final List<Tag> children = IteratorUtils.toList(tag.listChildren()); explodedTags.addAll(this.getExplodedTags(children, explodedTags)); } else { log.debug("Add tag: {}", tag.getTagID()); explodedTags.add(tag.getTagID()); } } return explodedTags; }
From source file:jef.database.DbUtils.java
/** * ????//from w ww. j a v a2 s .co m * * @param subs * @param container * @return * @throws SQLException */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected static Object toProperContainerType(Collection<? extends IQueryableEntity> subs, Class<?> container, Class<?> bean, AbstractRefField config) throws SQLException { if (container.isAssignableFrom(subs.getClass())) { return subs; } if (container == Set.class) { HashSet set = new HashSet(); set.addAll(subs); return set; } else if (container == List.class) { ArrayList list = new ArrayList(); list.addAll(subs); return list; } else if (container == Array.class) { return subs.toArray(); } else if (container == Map.class) { Cascade cascade = config.getCascadeInfo(); if (cascade == null) { throw new SQLException("@Cascade annotation is required for Map mapping " + config.toString()); } Map map = new HashMap(); String key = cascade.keyOfMap(); BeanAccessor ba = FastBeanWrapperImpl.getAccessorFor(bean); if (StringUtils.isEmpty(cascade.valueOfMap())) { for (IQueryableEntity e : subs) { map.put(ba.getProperty(e, key), e); } } else { String vField = cascade.valueOfMap(); for (IQueryableEntity e : subs) { map.put(ba.getProperty(e, key), ba.getProperty(e, vField)); } } return map; } throw new SQLException("the type " + container.getName() + " is not supported as a collection container."); }
From source file:com.act.reachables.Network.java
void addNode(Node n, Long nid) { if (this.nodeMapping.containsKey(n)) { if (!Boolean.valueOf((String) Node.getAttribute(n.id, "isrxn"))) { return; }/* w w w . j a v a 2s .c om*/ Node currentNode = this.nodeMapping.get(n); if (Node.getAttribute(nid, "reaction_ids") != null) { HashSet s = ((HashSet) Node.getAttribute(currentNode.id, "reaction_ids")); s.addAll((HashSet) Node.getAttribute(nid, "reaction_ids")); Node.setAttribute(currentNode.id, "reaction_ids", s); Node.setAttribute(currentNode.id, "reaction_count", s.size()); } if (Node.getAttribute(nid, "organisms") != null) { HashSet orgs = ((HashSet) Node.getAttribute(currentNode.id, "organisms")); orgs.addAll((HashSet) Node.getAttribute(nid, "organisms")); Node.setAttribute(currentNode.id, "organisms", orgs); } } else { this.idToNode.put(nid, n); this.nodeMapping.put(n, n); this.nids.put(n, nid); } }
From source file:de.ks.flatadocdb.session.Session.java
@SuppressWarnings("unchecked") public <R, E, V> Set<V> queryValues(Class<R> resultClass, Query<E, V> query, Predicate<V> filter) { Set<V> filteredFromSession = this.entriesById.values().stream()// .filter(entry -> resultClass.isAssignableFrom(entry.getObject().getClass()))// .map(entry -> query.getValue((E) entry.getObject()))// .filter(Objects::nonNull)// .filter(filter::test)// .collect(Collectors.toSet()); Set<V> fromIndex = queryValuesFromIndex(query, filter, entriesById.keySet()); HashSet<V> retval = new HashSet<>(fromIndex); retval.addAll(filteredFromSession); return retval; }