List of usage examples for java.util Set contains
boolean contains(Object o);
From source file:io.wcm.caravan.pipeline.extensions.hal.action.RemoveAllProperties.java
/** * Removes all properties except the specified ones from the given resource and all embedded resources * @param hal a HAL resource//from ww w.ja v a 2s . c o m * @param propertiesToKeep all properties that should be left untouched */ public static void removePropertiesRecursive(HalResource hal, Set<String> propertiesToKeep) { // remove properties hal.getStateFieldNames().stream().filter(property -> !propertiesToKeep.contains(property)) .forEach(property -> hal.getModel().remove(property)); // check embedded resources hal.getEmbedded().values().stream() .forEach(embedded -> removePropertiesRecursive(embedded, propertiesToKeep)); }
From source file:com.jstar.eclipse.objects.JavaFilePersistentProperties.java
public static void setDebugModes(JavaFile javaFile, Set<DebugMode> modes) { setDebugMode(javaFile, DebugMode.SYMBOLIC, modes.contains(DebugMode.SYMBOLIC)); setDebugMode(javaFile, DebugMode.CORE, modes.contains(DebugMode.CORE)); setDebugMode(javaFile, DebugMode.PARSING, modes.contains(DebugMode.PARSING)); setDebugMode(javaFile, DebugMode.SMT, modes.contains(DebugMode.SMT)); }
From source file:Main.java
public static double calcStrSetSimilarity(final Set<String> strASet1, final Set<String> strASet2) { int containsCount = 0; final Iterator<String> iter = strASet2.iterator(); while (iter.hasNext()) { if (strASet1.contains(iter.next())) { containsCount++;//from w w w . java 2 s .co m } } return (double) containsCount / (double) strASet1.size(); }
From source file:Main.java
/** * @param values1 to intersect with values2 * @param values2 to intersect with values1 * @param <T> type/*w w w.j a v a2 s. co m*/ * @return the intersection of values1 and values2 with unique values ordered by values1 */ public static <T> List<T> intersection(Collection<T> values1, Collection<T> values2) { Set<T> added = new HashSet<T>(), set2 = new HashSet<T>(values2); List<T> results = new ArrayList<T>(); for (T value : values1) { if (set2.contains(value) && !added.contains(value)) { results.add(value); added.add(value); } } return results; }
From source file:Main.java
public static <T> List<T> intersect(List<T> list1, Set<T> set2) { List<T> intersection = new ArrayList<>(set2.size()); for (T e : list1) { if (set2.contains(e)) { intersection.add(e);/*w w w .ja v a2s . c o m*/ } } return intersection; }
From source file:com.nsn.squirrel.tab.utils.PathUtils.java
/** * @param path//w ww. ja va 2s. com * @return */ public static String getAttributesString(Path path) { Set<String> views = FileSystems.getDefault().supportedFileAttributeViews(); if (views.contains("posix")) { //$NON-NLS-1$ return getPosixAttributesString(path); } else { return getDosAttributesString(path); } }
From source file:Main.java
public static <E> boolean areDisjoint(Set<E> setOne, Set<E> setTwo) { if (setOne == null || setTwo == null) { return true; }//from w w w. j a v a2 s . c o m Set<E> smallerSet = setOne; Set<E> largerSet = setTwo; if (setOne.size() > setTwo.size()) { smallerSet = setTwo; largerSet = setOne; } for (E el : smallerSet) { if (largerSet.contains(el)) { return false; } } return true; }
From source file:Main.java
/** * @return all the Strings in the array words which are present in the Set filter */// w w w.j a v a2 s . c o m static String[] filter(String[] words, Set<String> filter) { if (words == null) return new String[0]; List<String> filteredWords = new ArrayList<>(); for (String word : words) { if (filter.contains(word)) filteredWords.add(word); } return filteredWords.toArray(new String[filteredWords.size()]); }
From source file:cane.brothers.e4.commander.utils.PathUtils.java
/** * @param path/*from w w w. j a v a2s . c om*/ * @return */ public static String getAttributesString(Path path) { Set<String> views = FileSystems.getDefault().supportedFileAttributeViews(); if (views.contains("posix")) { //$NON-NLS-1$ return getPosixAttributesString(path); } else { return getDosAttributesString(path); } }
From source file:Main.java
public static String ensureUnique(Set<String> nameSet, String name) { String paramName = name;/*w w w . java 2 s .co m*/ if (null != paramName && -1 != paramName.indexOf(".")) { paramName = paramName.replace('.', '_'); } if (nameSet.contains(paramName)) { int index = 1; String tempVar = null; while (true) { tempVar = paramName + "_" + index; if (!nameSet.contains(tempVar)) { break; } index++; } paramName = tempVar; } return paramName; }