List of usage examples for java.util Set contains
boolean contains(Object o);
From source file:Main.java
/** * Filters duplicate formulas from the given list of formulas.<br/> * <b>TODO:</b> Filter method does not consider AST, it compares only the string representation. * @param formulas Formulas, which shall be filtered (may contain duplicates). Must not be <tt>null</tt>. * @return The filtered list of duplicate, won't be <tt>null</tt>. *//*from w w w. j av a 2 s . co m*/ public static List<String> filterDuplicates(List<String> formulas) { // Current equality check is only done on String.equals -> this could be improved Set<String> alreadyCollectedFormulas = new HashSet<>(); List<String> results = new ArrayList<>(); for (int i = 0; i < formulas.size(); i++) { String currentFormula = formulas.get(i); if (!alreadyCollectedFormulas.contains(currentFormula)) { alreadyCollectedFormulas.add(currentFormula); results.add(currentFormula); } } if (results.size() < formulas.size()) { int skipped = formulas.size() - results.size(); System.out.println("Skipped " + skipped + " from " + formulas.size()); } return results; }
From source file:net.openid.appauth.AdditionalParamsProcessor.java
static Map<String, String> extractAdditionalParams(UriParser uri, Set<String> builtInParams) { Map<String, String> additionalParams = new LinkedHashMap<>(); for (String param : uri.getQueryParameterNames()) { if (!builtInParams.contains(param)) { additionalParams.put(param, uri.getQueryParameter(param)); }//from w w w. j a v a 2 s .c o m } return additionalParams; }
From source file:de.unisb.cs.st.javalanche.mutation.results.MutationCoverageFile.java
public static boolean isCovered(long id) { Set<Long> covered = getCoveredMutations(); return covered != null && covered.contains(id); }
From source file:piecework.util.ContentUtility.java
public static boolean validateScheme(URI uri, Set<String> validSchemes) throws PieceworkException { String scheme = uri.getScheme(); return StringUtils.isNotEmpty(scheme) && validSchemes != null && validSchemes.contains(scheme); }
From source file:ai.serotonin.haystack.validator.Source.java
/** * Remove all tags that are not in the Project-Haystack spec. * /*from w w w . jav a 2s.com*/ * @param row * @throws Exception */ public static void clean(HMap row) throws Exception { Set<String> tags = Tags.getTags(); Set<String> keyDump = new HashSet<>(); for (String key : row.keySet()) { if (!tags.contains(key)) keyDump.add(key); } for (String key : keyDump) row.delete(key); }
From source file:com.hack23.cia.service.data.impl.util.LoadHelper.java
/** * Recursive initliaze.//w ww .j a v a 2 s . c o m * * @param obj * the obj * @param dejaVu * the deja vu * @throws IllegalAccessException * the illegal access exception * @throws InvocationTargetException * the invocation target exception * @throws NoSuchMethodException * the no such method exception */ private static void recursiveInitialize(final Object obj, final Set<Object> dejaVu) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { if (dejaVu.contains(obj)) { return; } else { dejaVu.add(obj); if (!Hibernate.isInitialized(obj)) { Hibernate.initialize(obj); } if (obj instanceof HibernateProxy || obj instanceof PersistentCollection) { initProxyAndCollections(obj, PropertyUtils.getPropertyDescriptors(obj), dejaVu); } } }
From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilter.java
static boolean match(final Issue issue, final IssuePattern pattern) { final boolean isMatchingResource = matchResource(issue.componentKey(), pattern.getResourcePattern()); if (!isMatchingResource) { return false; }/* w w w .ja v a 2 s. co m*/ final boolean isMatchingRule = matchRule(issue.ruleKey(), pattern.getRulePattern()); if (!isMatchingRule) { return false; } final Set<Integer> lines = pattern.getLines(); if (lines.isEmpty()) { return true; // empty is any line } return lines.contains(issue.line()); }
From source file:de.hasait.genesis.base.util.GenesisUtils.java
public static boolean isPublicMemberMethod(final Element pElement) { if (pElement != null && pElement.getKind() == ElementKind.METHOD) { final Set<Modifier> modifiers = pElement.getModifiers(); return modifiers.contains(Modifier.PUBLIC) && !modifiers.contains(Modifier.STATIC); }/*w w w . j av a2s. co m*/ return false; }
From source file:biomine.bmvis2.subgraph.Extractor.java
public static void removeAllExceptEdges(VisualGraph g, Set<VisualEdge> keepers) { Set<VisualEdge> newHidden = new HashSet<VisualEdge>(); for (VisualEdge edge : g.getAllEdges()) if (!keepers.contains(edge)) newHidden.add(edge);/*from w ww .j a v a 2s.c om*/ for (VisualEdge edge : newHidden) g.deleteEdge(edge); }
From source file:au.org.ala.delta.intkey.model.FormattingUtils.java
/** * Formats the values set for an integer character as a string. It is * assumed the values for the integer character have already been processed * such that they are in the range minimumValue - 1 to maximumValue + 1. * /*from ww w.j a v a 2 s .c om*/ * @param integerValues * the values set for the integer character * @param minimumValue * the character's minimum value * @param maximumValue * the character's maximum value * @return the integer character's values formatted as a string. */ public static String formatIntegerValuesAsString(Set<Integer> integerValues, int minimumValue, int maximumValue) { Set<Integer> valuesCopy = new HashSet<Integer>(integerValues); List<String> stringParts = new ArrayList<String>(); if (integerValues.contains(minimumValue - 1)) { stringParts.add(Integer.toString(minimumValue - 1)); } valuesCopy.remove(minimumValue - 1); valuesCopy.remove(maximumValue + 1); if (!valuesCopy.isEmpty()) { List<Integer> valuesCopyAsList = new ArrayList<Integer>(valuesCopy); Collections.sort(valuesCopyAsList); stringParts.add(Utils.formatIntegersAsListOfRanges(valuesCopyAsList, "/", "-")); } if (integerValues.contains(maximumValue + 1)) { stringParts.add(Integer.toString(maximumValue + 1)); } return StringUtils.join(stringParts, "/"); }