List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:org.camunda.bpm.spring.boot.starter.property.CamundaBpmProperties.java
static String[] initDeploymentResourcePattern() { final Set<String> suffixes = new HashSet<String>(); suffixes.addAll(Arrays.asList(DEFAULT_DMN_RESOURCE_SUFFIXES)); suffixes.addAll(Arrays.asList(DEFAULT_BPMN_RESOURCE_SUFFIXES)); suffixes.addAll(Arrays.asList(DEFAULT_CMMN_RESOURCE_SUFFIXES)); final Set<String> patterns = new HashSet<String>(); for (String suffix : suffixes) { patterns.add(String.format("%s**/*.%s", CLASSPATH_ALL_URL_PREFIX, suffix)); }/*from w w w . ja va 2s. com*/ return patterns.toArray(new String[patterns.size()]); }
From source file:com.github.juanmf.java2plant.Parser.java
private static Set<Class<?>> getTypes(String packageToPase, List<ClassLoader> classLoadersList) { Collection<URL> urls = getUrls(classLoadersList); Set<Class<?>> classes = new HashSet<>(); for (String aPackage : TypesHelper.splitPackages(packageToPase)) { classes.addAll(getPackageTypes(aPackage, urls)); }// w w w . j a va2 s .com addSuperClassesAndInterfaces(classes); return classes; }
From source file:net.big_oh.common.web.listener.session.SimpleSessionTrackingListener.java
/** * /* w w w .ja va 2s . c o m*/ * @return Returns a set of all <code>HttpSession</code> objects observed by * web applications that used the same classloader to instantiate * the <code>HttpSessionListener</code> listener. */ // TODO DSW Need better documentation here public static synchronized Set<HttpSession> getSessionsForClassloader() { Set<HttpSession> sessionsForJvm = new HashSet<HttpSession>(); for (String servletContextKey : contextToSessionCollectionMap.keySet()) { Map<HttpSession, Object> sessionsMapForServletContext = contextToSessionCollectionMap .get(servletContextKey); sessionsForJvm.addAll(sessionsMapForServletContext.keySet()); } return sessionsForJvm; }
From source file:de.tudarmstadt.ukp.lmf.hibernate.HibernateConnect.java
/** * Returns all files from the folder and its subfolders * * @deprecated this method is marked for deletion *///from w w w. java 2s . c o m @Deprecated public static Set<File> getAllFiles(File folder) { Set<File> result = new HashSet<File>(); if (folder.isFile() && folder.getName().endsWith(".hbm.xml")) { result.add(folder); } else if (folder.isDirectory()) { for (File f : folder.listFiles()) { result.addAll(getAllFiles(f)); } } return result; }
From source file:io.fabric8.maven.core.config.ProcessorConfig.java
private static Set<String> mergeExcludes(ProcessorConfig... configs) { Set<String> ret = new HashSet<>(); for (ProcessorConfig config : configs) { if (config != null) { Set<String> excludes = config.excludes; if (excludes != null) { ret.addAll(excludes); }/*from www . ja va2 s. c o m*/ } } return ret; }
From source file:com.kylinolap.metadata.tool.HiveSourceTableLoader.java
public static Set<String> reloadHiveTables(String[] hiveTables, KylinConfig config) throws IOException { Map<String, Set<String>> db2tables = Maps.newHashMap(); for (String table : hiveTables) { int cut = table.indexOf('.'); String database = cut >= 0 ? table.substring(0, cut).trim() : "DEFAULT"; String tableName = cut >= 0 ? table.substring(cut + 1).trim() : table.trim(); Set<String> set = db2tables.get(database); if (set == null) { set = Sets.newHashSet();//from www. j a va2s. co m db2tables.put(database, set); } set.add(tableName); } // metadata tmp dir File metaTmpDir = File.createTempFile("meta_tmp", null); metaTmpDir.delete(); metaTmpDir.mkdirs(); for (String database : db2tables.keySet()) { for (String table : db2tables.get(database)) { TableDesc tableDesc = MetadataManager.getInstance(config).getTableDesc(table); if (tableDesc == null) { continue; } if (tableDesc.getDatabase().equalsIgnoreCase(database)) { continue; } else { throw new UnsupportedOperationException( String.format("there is already a table[%s] in database[%s]", tableDesc.getName(), tableDesc.getDatabase())); } } } // extract from hive Set<String> loadedTables = Sets.newHashSet(); for (String database : db2tables.keySet()) { List<String> loaded = extractHiveTables(database, db2tables.get(database), metaTmpDir, config); loadedTables.addAll(loaded); } // save loaded tables ResourceTool.copy(KylinConfig.createInstanceFromUri(metaTmpDir.getAbsolutePath()), config); return loadedTables; }
From source file:io.fabric8.kit.enricher.api.EnrichersConfig.java
@SafeVarargs private static <P extends ProjectContext> Set<String> mergeExcludes(EnrichersConfig<P>... configs) { Set<String> ret = new HashSet<>(); for (EnrichersConfig<P> config : configs) { if (config != null) { Set<String> excludes = config.excludes; if (excludes != null) { ret.addAll(excludes); }//from www. j a v a 2 s . c om } } return ret; }
From source file:net.sf.morph.util.TransformerUtils.java
private static Class[] getClassIntersection(Transformer[] transformers, ClassStrategy strategy) { Set s = ContainerUtils.createOrderedSet(); s.addAll(Arrays.asList(strategy.get(transformers[0]))); for (int i = 1; i < transformers.length; i++) { Set survivors = ContainerUtils.createOrderedSet(); Class[] c = strategy.get(transformers[i]); for (int j = 0; j < c.length; j++) { if (s.contains(c[j])) { survivors.add(c[j]);// w w w .j a v a 2 s .c o m break; } if (c[j] == null) { break; } for (Iterator it = s.iterator(); it.hasNext();) { Class next = (Class) it.next(); if (next != null && next.isAssignableFrom(c[j])) { survivors.add(c[j]); break; } } } if (!survivors.containsAll(s)) { for (Iterator it = s.iterator(); it.hasNext();) { Class next = (Class) it.next(); if (survivors.contains(next) || next == null) { break; } for (int j = 0; j < c.length; j++) { if (c[j] != null && c[j].isAssignableFrom(next)) { survivors.add(next); break; } } } } s = survivors; } return s.isEmpty() ? CLASS_NONE : (Class[]) s.toArray(new Class[s.size()]); }
From source file:com.shazam.shazamcrest.matcher.GsonProvider.java
@SuppressWarnings("unchecked") private static Set<Object> orderSetByElementsJsonRepresentation(Set set, final Gson gson) { Set<Object> objects = newTreeSet(new Comparator<Object>() { @Override//from w w w. j av a2 s .c o m public int compare(Object o1, Object o2) { return gson.toJson(o1).compareTo(gson.toJson(o2)); } }); objects.addAll(set); return objects; }
From source file:edu.wpi.checksims.algorithm.similaritymatrix.SimilarityMatrix.java
/** * Generate a Similarity Matrix with archive submissions. * * The result is not a square matrix. Only the input submissions are on the X axis, but the Y axis contains both * input and archive submissions.//from w w w .j ava2s .c om * * @param inputSubmissions Submissions used to generate matrix * @param archiveSubmissions Archive submissions - only compared to input submissions, not to each other * @param results Results used to build matrix * @return Similarity matrix built from given results * @throws InternalAlgorithmError Thrown on missing results, or results containing a submission not in the input */ public static SimilarityMatrix generateMatrix(Set<Submission> inputSubmissions, Set<Submission> archiveSubmissions, Set<AlgorithmResults> results) throws InternalAlgorithmError { checkNotNull(inputSubmissions); checkNotNull(archiveSubmissions); checkNotNull(results); checkArgument(!inputSubmissions.isEmpty(), "Must provide at least 1 submission to build matrix from"); checkArgument(!results.isEmpty(), "Must provide at least 1 AlgorithmResults to build matrix from!"); Set<Submission> setOfBoth = new HashSet<>(); setOfBoth.addAll(inputSubmissions); setOfBoth.addAll(archiveSubmissions); checkArgument(setOfBoth.size() == (archiveSubmissions.size() + inputSubmissions.size()), "Some submissions were found in both archive and input submissions!"); // If there are no archive submissions, just generate using the other function if (archiveSubmissions.isEmpty()) { return generateMatrix(inputSubmissions, results); } List<Submission> xSubmissions = Ordering.natural().immutableSortedCopy(inputSubmissions); List<Submission> ySubmissions = new ArrayList<>(); ySubmissions.addAll(Ordering.natural().immutableSortedCopy(inputSubmissions)); ySubmissions.addAll(Ordering.natural().immutableSortedCopy(archiveSubmissions)); MatrixEntry[][] matrix = new MatrixEntry[xSubmissions.size()][ySubmissions.size()]; // Generate the matrix // First, handle identical submissions for (Submission xSub : xSubmissions) { // Get the X index int xIndex = xSubmissions.indexOf(xSub); int yIndex = ySubmissions.indexOf(xSub); matrix[xIndex][yIndex] = new MatrixEntry(xSub, xSub, xSub.getNumTokens()); } // Now iterate through all given algorithm results for (AlgorithmResults result : results) { int aXCoord = xSubmissions.indexOf(result.a); int bXCoord = xSubmissions.indexOf(result.b); if (aXCoord == -1 && bXCoord == -1) { throw new InternalAlgorithmError("Neither submission \"" + result.a.getName() + "\" nor \"" + result.b.getName() + "\" were found in input submissions!"); } if (aXCoord != -1) { int bYCoord = ySubmissions.indexOf(result.b); matrix[aXCoord][bYCoord] = new MatrixEntry(result.a, result.b, result.identicalTokensA); } if (bXCoord != -1) { int aYCoord = ySubmissions.indexOf(result.a); matrix[bXCoord][aYCoord] = new MatrixEntry(result.b, result.a, result.identicalTokensB); } } // Verification pass - ensure we built a matrix with no nulls for (int x = 0; x < xSubmissions.size(); x++) { for (int y = 0; y < ySubmissions.size(); y++) { if (matrix[x][y] == null) { throw new InternalAlgorithmError("Missing Algorithm Results for comparison of submissions \"" + xSubmissions.get(x).getName() + "\" and \"" + ySubmissions.get(y).getName() + "\""); } } } return new SimilarityMatrix(matrix, xSubmissions, ySubmissions, results); }