List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:net.itransformers.topologyviewer.fulfilmentfactory.impl.TestFulfilmentImpl.java
Set<String> readVars(String line) { String varsStr = line.substring("### vars:".length()).trim(); String[] varsArr = varsStr.split(",\\s"); Set<String> vars = new HashSet<String>(varsArr.length); vars.addAll(Arrays.asList(varsArr)); return vars;/*from ww w. j a v a 2s .c o m*/ }
From source file:cc.recommenders.utils.dictionary.Dictionary.java
public Set<T> getAllEntries() { Set<T> allEntries = new LinkedHashSet<T>(); allEntries.addAll(entries); return allEntries; }
From source file:com.amazon.janusgraph.example.MarvelGraphFactory.java
public static void load(final JanusGraph graph, final int rowsToLoad, final boolean report) throws Exception { JanusGraphManagement mgmt = graph.openManagement(); if (mgmt.getGraphIndex(CHARACTER) == null) { final PropertyKey characterKey = mgmt.makePropertyKey(CHARACTER).dataType(String.class).make(); mgmt.buildIndex(CHARACTER, Vertex.class).addKey(characterKey).unique().buildCompositeIndex(); }//from www. java 2 s.c o m if (mgmt.getGraphIndex(COMIC_BOOK) == null) { final PropertyKey comicBookKey = mgmt.makePropertyKey(COMIC_BOOK).dataType(String.class).make(); mgmt.buildIndex(COMIC_BOOK, Vertex.class).addKey(comicBookKey).unique().buildCompositeIndex(); mgmt.makePropertyKey(WEAPON).dataType(String.class).make(); mgmt.makeEdgeLabel(APPEARED).multiplicity(Multiplicity.MULTI).make(); } mgmt.commit(); ClassLoader classLoader = MarvelGraphFactory.class.getClassLoader(); URL resource = classLoader.getResource("META-INF/marvel.csv"); int line = 0; Map<String, Set<String>> comicToCharacter = new HashMap<>(); Map<String, Set<String>> characterToComic = new HashMap<>(); Set<String> characters = new HashSet<>(); BlockingQueue<Runnable> creationQueue = new LinkedBlockingQueue<>(); try (CSVReader reader = new CSVReader(new InputStreamReader(resource.openStream()))) { String[] nextLine; while ((nextLine = reader.readNext()) != null && line < rowsToLoad) { line++; String comicBook = nextLine[1]; String[] characterNames = nextLine[0].split("/"); if (!comicToCharacter.containsKey(comicBook)) { comicToCharacter.put(comicBook, new HashSet<String>()); } List<String> comicCharacters = Arrays.asList(characterNames); comicToCharacter.get(comicBook).addAll(comicCharacters); characters.addAll(comicCharacters); } } for (String character : characters) { creationQueue.add(new CharacterCreationCommand(character, graph)); } BlockingQueue<Runnable> appearedQueue = new LinkedBlockingQueue<>(); for (String comicBook : comicToCharacter.keySet()) { creationQueue.add(new ComicBookCreationCommand(comicBook, graph)); Set<String> comicCharacters = comicToCharacter.get(comicBook); for (String character : comicCharacters) { AppearedCommand lineCommand = new AppearedCommand(graph, new Appeared(character, comicBook)); appearedQueue.add(lineCommand); if (!characterToComic.containsKey(character)) { characterToComic.put(character, new HashSet<String>()); } characterToComic.get(character).add(comicBook); } REGISTRY.histogram("histogram.comic-to-character").update(comicCharacters.size()); } int maxAppearances = 0; String maxCharacter = ""; for (String character : characterToComic.keySet()) { Set<String> comicBookSet = characterToComic.get(character); int numberOfAppearances = comicBookSet.size(); REGISTRY.histogram("histogram.character-to-comic").update(numberOfAppearances); if (numberOfAppearances > maxAppearances) { maxCharacter = character; maxAppearances = numberOfAppearances; } } LOG.info("Character {} has most appearances at {}", maxCharacter, maxAppearances); ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE); for (int i = 0; i < POOL_SIZE; i++) { executor.execute(new BatchCommand(graph, creationQueue)); } executor.shutdown(); while (!executor.awaitTermination(60, TimeUnit.SECONDS)) { LOG.info("Awaiting:" + creationQueue.size()); if (report) { REPORTER.report(); } } executor = Executors.newSingleThreadExecutor(); executor.execute(new BatchCommand(graph, appearedQueue)); executor.shutdown(); while (!executor.awaitTermination(60, TimeUnit.SECONDS)) { LOG.info("Awaiting:" + appearedQueue.size()); if (report) { REPORTER.report(); } } LOG.info("MarvelGraphFactory.load complete"); }
From source file:info.archinnov.achilles.internal.metadata.parsing.EntityExplorer.java
public List<Class<?>> discoverEntities(List<String> packageNames) { log.debug("Discovery of Achilles entity classes in packages {}", StringUtils.join(packageNames, ",")); Set<Class<?>> candidateClasses = new HashSet<Class<?>>(); Reflections reflections = new Reflections(packageNames); candidateClasses.addAll(reflections.getTypesAnnotatedWith(Entity.class)); return new ArrayList<Class<?>>(candidateClasses); }
From source file:net.sf.gazpachoquest.services.user.impl.UserServiceImpl.java
@Override @Transactional(readOnly = true)//w ww . j ava2 s.co m public Set<Permission<?>> getPermissions(Integer userId) { Set<Permission<?>> permissions = new HashSet<Permission<?>>(); permissions.addAll(((UserRepository) repository).getQuestionnairPermissions(userId)); permissions.addAll(((UserRepository) repository).getQuestionnairDefinitionPermissions(userId)); permissions.addAll(((UserRepository) repository).getResearchPermissions(userId)); permissions.addAll(((UserRepository) repository).getUserPermissions(userId)); return permissions; }
From source file:ca.simplegames.micro.utils.StringUtils.java
/** * Convenience method to convert a CSV string list to a set. * Note that this will suppress duplicates. * * @param str the input String// w ww . jav a2 s.c o m * @return a Set of String entries in the list */ public static Set commaDelimitedListToSet(String str) { Set set = new TreeSet(); String[] tokens = commaDelimitedListToStringArray(str); set.addAll(Arrays.asList(tokens)); return set; }
From source file:info.archinnov.achilles.entity.parsing.EntityExplorer.java
public List<Class<?>> discoverEntities(List<String> packageNames) throws ClassNotFoundException, IOException { log.debug("Discovery of Achilles entity classes in packages {}", StringUtils.join(packageNames, ",")); Set<Class<?>> candidateClasses = new HashSet<Class<?>>(); Reflections reflections = new Reflections(packageNames); candidateClasses.addAll(reflections.getTypesAnnotatedWith(Entity.class)); return new ArrayList<Class<?>>(candidateClasses); }
From source file:com.thoughtworks.go.util.Csv.java
private Set<String> fields() { Set<String> fields = new LinkedHashSet<>(); for (CsvRow row : data) { fields.addAll(row.fields()); }/*from w w w . j a v a 2s. c om*/ return fields; }
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)); }//from w ww . j a v a2 s . c o m return new DomainMap(domainsMap); }
From source file:com.gopivotal.cloudfoundry.test.support.runner.BuildpackClassRunner.java
private Set<String> getExcludedApplicationNames(Method method) { Set<String> names = new HashSet<>(); names.addAll(nullSafeValue(AnnotationUtils.findAnnotation(method, ExcludedApplications.class))); names.addAll(nullSafeValue(//w w w. ja v a2s . c o m AnnotationUtils.findAnnotation(method.getDeclaringClass(), ExcludedApplications.class))); return names; }