List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:com.github.juanmf.java2plant.Parser.java
private static void addSuperClassesAndInterfaces(Set<Class<?>> classes) { Set<Class<?>> newClasses = new HashSet<>(); for (Class<?> c : classes) { addSuperClass(c, newClasses);//from www . j a va 2 s . co m addInterfaces(c, newClasses); } classes.addAll(newClasses); }
From source file:biz.netcentric.cq.tools.actool.acls.AceBeanInstallerImpl.java
/** Modifies the privileges so that privileges already covered by actions are removed. This is only a best effort operation as one * action can lead to privileges on multiple nodes. * * @throws RepositoryException */ private static Set<String> removeRedundantPrivileges(Session session, String[] privileges, String[] actions) throws RepositoryException { final CqActions cqActions = new CqActions(session); final Set<String> cleanedPrivileges = new HashSet<String>(); if (privileges == null) { return cleanedPrivileges; }// w w w .j a v a 2s. co m cleanedPrivileges.addAll(Arrays.asList(privileges)); if (actions == null) { return cleanedPrivileges; } for (final String action : actions) { @SuppressWarnings("deprecation") final Set<Privilege> coveredPrivileges = cqActions.getPrivileges(action); for (final Privilege coveredPrivilege : coveredPrivileges) { cleanedPrivileges.remove(coveredPrivilege.getName()); } } return cleanedPrivileges; }
From source file:com.alibaba.jstorm.ui.UIUtils.java
public static List<String> getSortedKeys(Set<String> keys) { List<String> ret = new ArrayList<String>(); Set<String> temp = new TreeSet<String>(); temp.addAll(keys); checkKey(ret, temp, MetricDef.CPU_USED_RATIO); checkKey(ret, temp, MetricDef.MEMORY_USED); checkKey(ret, temp, MetricDef.SEND_TPS); checkKey(ret, temp, MetricDef.RECV_TPS); checkKey(ret, temp, MetricDef.EMMITTED_NUM); checkKey(ret, temp, MetricDef.ACKED_NUM); checkKey(ret, temp, MetricDef.FAILED_NUM); checkKey(ret, temp, MetricDef.PROCESS_LATENCY); ret.addAll(temp);//w ww .j a va 2 s .c o m return ret; }
From source file:com.mg.framework.utils.DatabaseUtils.java
/** * ? ?? ? ??, ????// w w w .j a va2s. c om * ? '<strong>,</strong>' <p> ?: * <blockquote><pre> * fieldsSet = DatabaseUtils.generateDefaultFieldsSet("Id,Code,Name", service)); * </pre></blockquote> * * @param fieldsSet ? ? * @param service ?- * @return ? */ public static Set<String> generateDefaultFieldsSet(final String fieldsSet, DataBusinessObjectService<? extends PersistentObject, ? extends Serializable> service) { Set<String> result = new LinkedHashSet<String>(); result.addAll(StringUtils.split(fieldsSet, ",")); //$NON-NLS-1$ return DatabaseUtils.embedAddinFieldsDefaultFieldsSet(result, service); }
From source file:de.micromata.tpsb.doc.StaticTestDocGenerator.java
private static void readLocalSettings(Builder bCfg, Builder tCfg) { TpsbProjectCatalog catalog = new TpsbProjectCatalog(); // catalog.initFromLocalSettings(); if (StringUtils.isNotEmpty(catalog.getHtmlOutputPath()) == true) { tCfg.outputDir(catalog.getHtmlOutputPath()); bCfg.outputDir(catalog.getHtmlOutputPath()); TpsbEnvironment.setBaseDir(catalog.getHtmlOutputPath()); }//from w ww.j a v a 2 s. co m if (StringUtils.isNotEmpty(catalog.getVmIndex()) == true) { StringResourceRepository repo = StringResourceLoader.getRepository(); repo.putStringResource("customIndexTemplate", getUtf8Content(new File(catalog.getVmIndex())), CharEncoding.UTF_8); tCfg.indexTemplate("customIndexTemplate"); } if (StringUtils.isNotEmpty(catalog.getVmTest()) == true) { String content = getUtf8Content(new File(catalog.getVmTest())); StringResourceRepository repo = StringResourceLoader.getRepository(); repo.putStringResource("customTestTemplate", content, CharEncoding.UTF_8); tCfg.testTemplate("customTestTemplate"); } if (StringUtils.isNotEmpty(catalog.getVmCssFile()) == true) { File sf = new File(catalog.getVmCssFile()); if (sf.exists() == false) { log.warn("vmCssFile does not exists: " + sf.getAbsolutePath()); } else { File targetFile = new File(new File(catalog.getHtmlOutputPath()), sf.getName()); try { FileUtils.copyFile(sf, targetFile); } catch (IOException ex) { log.warn("Cannot copy file " + sf.getAbsolutePath() + " to " + targetFile.getAbsolutePath() + ": " + ex.getMessage(), ex); } } } Set<String> importedProjects = new HashSet<String>(); for (String pn : catalog.getProjectNames()) { TpsbProject project = catalog.getProject(pn); importedProjects.addAll(project.getImportedProjects()); File f = new File(project.getProjectPath()); TpsbEnvironment.get().addProjectRoots(f); if (project.getSourceDirs().isEmpty() == false) { for (String sourceDir : project.getSourceDirs()) { if (project.isNoTestCases() == false) { tCfg.addSourceFileRespository(new FileSystemSourceFileRepository(sourceDir)); } bCfg.addSourceFileRespository(new FileSystemSourceFileRepository(sourceDir)); } } else { File ts = new File(f, "src/test"); if (ts.exists() == true) { if (project.isNoTestCases() == false) { tCfg.addSourceFileRespository(new FileSystemSourceFileRepository(ts.getAbsolutePath())); } bCfg.addSourceFileRespository(new FileSystemSourceFileRepository(ts.getAbsolutePath())); } else if (f.exists() == true) { if (project.isNoTestCases() == false) { tCfg.addSourceFileRespository(new FileSystemSourceFileRepository(f.getAbsolutePath())); } bCfg.addSourceFileRespository(new FileSystemSourceFileRepository(f.getAbsolutePath())); } else { log.error("Cannot find directory: " + ts.getAbsolutePath() + " for TPSB project " + pn); } } } log.info("TPSB Projects: " + catalog.getProjectNames()); }
From source file:CV.java
public static Set<OWLIndividual> getTestingSet(List<OWLIndividual> examples, int[] splits, int fold) { int fromIndex; // we either start from 0 or after the last fold ended if (fold == 0) fromIndex = 0;/* ww w.j av a 2s.c o m*/ else fromIndex = splits[fold - 1]; // the split corresponds to the ends of the folds int toIndex = splits[fold]; // System.out.println("from " + fromIndex + " to " + toIndex); Set<OWLIndividual> testingSet = new HashSet<OWLIndividual>(); // +1 because 2nd element is exclusive in subList method testingSet.addAll(examples.subList(fromIndex, toIndex)); return testingSet; }
From source file:com.evolveum.midpoint.repo.sql.data.common.any.RAssignmentExtension.java
private static void copyFromJAXB(PrismContainerValue containerValue, RAssignmentExtension repo, RAssignmentExtensionType type, PrismContext prismContext) throws DtoTranslationException { RAnyConverter converter = new RAnyConverter(prismContext); Set<RAnyValue> values = new HashSet<RAnyValue>(); try {//from ww w . j a v a 2s. c om List<Item<?, ?>> items = containerValue.getItems(); for (Item item : items) { values.addAll(converter.convertToRValue(item, true)); } } catch (Exception ex) { throw new DtoTranslationException(ex.getMessage(), ex); } for (RAnyValue value : values) { ((RAExtValue) value).setAnyContainer(repo); ((RAExtValue) value).setExtensionType(type); if (value instanceof RAExtDate) { repo.getDates().add((RAExtDate) value); } else if (value instanceof RAExtLong) { repo.getLongs().add((RAExtLong) value); } else if (value instanceof RAExtReference) { repo.getReferences().add((RAExtReference) value); } else if (value instanceof RAExtString) { repo.getStrings().add((RAExtString) value); } else if (value instanceof RAExtPolyString) { repo.getPolys().add((RAExtPolyString) value); } else if (value instanceof RAExtBoolean) { repo.getBooleans().add((RAExtBoolean) value); } } repo.setStringsCount((short) repo.getStrings().size()); repo.setDatesCount((short) repo.getDates().size()); repo.setPolysCount((short) repo.getPolys().size()); repo.setReferencesCount((short) repo.getReferences().size()); repo.setLongsCount((short) repo.getLongs().size()); repo.setBooleansCount((short) repo.getBooleans().size()); }
From source file:com.google.uzaygezen.core.BoundedRollupTest.java
private static <V, K> Set<MapNode<K, V>> toIdentitySet(List<MapNode<K, V>> list) { Set<MapNode<K, V>> set = Collections.newSetFromMap(new IdentityHashMap<MapNode<K, V>, Boolean>()); set.addAll(list); Assert.assertEquals(list.size(), set.size()); return set;/*w ww .jav a 2 s . co m*/ }
From source file:edu.cmu.cs.lti.ark.fn.identification.latentmodel.LatentAlphabetCreationThreaded.java
/** * Combines the multiple alphabet files created by createLocalAlphabets into one * alphabet file/* www. j a va2 s . c o m*/ */ public static void combineAlphabets(File alphabetDir) throws IOException { final String[] files = alphabetDir.list(LOCAL_ALPHABET_FILENAME_FILTER); final Set<String> alphabet = Sets.newHashSet(); for (String file : files) { final String path = alphabetDir.getAbsolutePath() + "/" + file; if (logger.isLoggable(Level.INFO)) logger.info("reading path: " + path); final Map<String, Integer> localAlphabet = readAlphabetFile(path); alphabet.addAll(localAlphabet.keySet()); } writeAlphabetFile(alphabet, alphabetDir.getAbsolutePath() + "/" + ALPHABET_FILENAME); }
From source file:eu.itesla_project.modules.simulation.ImpactAnalysisTool.java
private static void writeCsv(Map<String, Map<SecurityIndexId, SecurityIndex>> securityIndexesPerCase, Path outputCsvFile) throws IOException { Objects.requireNonNull(outputCsvFile); Set<SecurityIndexId> securityIndexIds = new LinkedHashSet<>(); for (Map<SecurityIndexId, SecurityIndex> securityIndexesPerId : securityIndexesPerCase.values()) { if (securityIndexesPerId != null) { securityIndexIds.addAll(securityIndexesPerId.keySet()); }//ww w . j ava2 s . c o m } try (BufferedWriter writer = Files.newBufferedWriter(outputCsvFile, StandardCharsets.UTF_8)) { writer.write("Base case"); for (SecurityIndexId securityIndexId : securityIndexIds) { writer.write(CSV_SEPARATOR); writer.write(securityIndexId.toString()); } writer.newLine(); for (Map.Entry<String, Map<SecurityIndexId, SecurityIndex>> entry : securityIndexesPerCase.entrySet()) { String baseCaseName = entry.getKey(); writer.write(baseCaseName); Map<SecurityIndexId, SecurityIndex> securityIndexes = entry.getValue(); for (SecurityIndexId securityIndexId : securityIndexIds) { Boolean b = null; if (securityIndexes != null) { SecurityIndex securityIndex = securityIndexes.get(securityIndexId); if (securityIndex != null) { b = securityIndex.isOk(); } } writer.write(CSV_SEPARATOR); writer.write(okToStr(b)); } writer.newLine(); } } }