List of usage examples for java.util Set contains
boolean contains(Object o);
From source file:edu.wpi.checksims.util.PairGeneratorTest.java
public static void checkPairsAreInSet(Set<Pair<Submission, Submission>> toCheck, Set<Pair<Submission, Submission>> expected) { assertNotNull(toCheck);/*from w w w.j a v a 2 s. c o m*/ assertNotNull(expected); assertEquals(expected.size(), toCheck.size()); expected.stream().forEach((pair) -> assertTrue( toCheck.contains(pair) || toCheck.contains(Pair.of(pair.getRight(), pair.getLeft())))); }
From source file:hudson.plugins.blazemeter.utils.Utils.java
public static List<BlazemeterCredentialsBAImpl> getCredentials(Object scope) { List<BlazemeterCredentialsBAImpl> result = new ArrayList<>(); Set<String> apiKeys = new HashSet<String>(); Item item = scope instanceof Item ? (Item) scope : null; for (BlazemeterCredentialsBAImpl c : CredentialsProvider .lookupCredentials(BlazemeterCredentialsBAImpl.class, item, ACL.SYSTEM)) { String id = c.getId();/*from ww w . j av a 2 s . co m*/ if (!apiKeys.contains(id)) { result.add(c); apiKeys.add(id); } } return result; }
From source file:de.tu_berlin.dima.oligos.Oligos.java
public static ColumnProfiler<?> getProfiler(final String schema, final String table, final String column, final TypeInfo type, final JdbcConnector jdbcConnector, final MetaConnector metaConnector) throws SQLException { ColumnProfiler<?> profiler = null; LOGGER.trace("type = " + type.toString()); String typeName = type.getTypeName().toLowerCase(); boolean isEnum = metaConnector.isEnumerated(schema, table, column); if (typeName.equals("smallint")) { Parser<Short> p = new ShortParser(); Operator<Short> op = new ShortOperator(); ColumnConnector<Short> connector = new Db2ColumnConnector<Short>(jdbcConnector, schema, table, column, p);//w w w .ja v a2 s.c o m profiler = new ColumnProfiler<Short>(schema, table, column, type, isEnum, connector, op, p); } else if (typeName.equals("integer")) { Parser<Integer> p = new IntegerParser(); Operator<Integer> op = new IntegerOperator(); ColumnConnector<Integer> connector = new Db2ColumnConnector<Integer>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<Integer>(schema, table, column, type, isEnum, connector, op, p); } else if (typeName.equals("bigint")) { Parser<Long> p = new LongParser(); Operator<Long> op = new LongOperator(); ColumnConnector<Long> connector = new Db2ColumnConnector<Long>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<Long>(schema, table, column, type, isEnum, connector, op, p); } else if (typeName.equals("decimal")) { Parser<BigDecimal> p = new BigDecimalParser(); Operator<BigDecimal> op = new BigDecimalOperator(); ColumnConnector<BigDecimal> connector = new Db2ColumnConnector<BigDecimal>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<BigDecimal>(schema, table, column, type, isEnum, connector, op, p); } else if (typeName.equals("float")) { Parser<Float> p = new FloatParser(); Operator<Float> op = new FloatOperator(); ColumnConnector<Float> connector = new Db2ColumnConnector<Float>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<Float>(schema, table, column, type, isEnum, connector, op, p); } else if (typeName.equals("double")) { Parser<Double> p = new DoubleParser(); Operator<Double> op = new DoubleOperator(); ColumnConnector<Double> connector = new Db2ColumnConnector<Double>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<Double>(schema, table, column, type, isEnum, connector, op, p); } else if (typeName.equals("timestamp")) { Parser<Timestamp> p = new TimestampParser(); Operator<Timestamp> op = new TimestampOperator(); ColumnConnector<Timestamp> connector = new Db2ColumnConnector<Timestamp>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<Timestamp>(schema, table, column, type, isEnum, connector, op, p); } else if (typeName.equals("time")) { Parser<Time> p = new TimeParser(); Operator<Time> op = new TimeOperator(); ColumnConnector<Time> connector = new Db2ColumnConnector<Time>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<Time>(schema, table, column, type, isEnum, connector, op, p); } else if (typeName.equals("date")) { Parser<Date> p = new DateParser(); Operator<Date> op = new DateOperator(); ColumnConnector<Date> connector = new Db2ColumnConnector<Date>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<Date>(schema, table, column, type, isEnum, connector, op, p); } else if ((typeName.equals("char") || typeName.equals("varchar")) && (type.getLength() == 1)) { Parser<Character> p = new CharParser(); Operator<Character> op = new CharOperator(); ColumnConnector<Character> connector = new Db2ColumnConnector<Character>(jdbcConnector, schema, table, column, p); profiler = new ColumnProfiler<Character>(schema, table, column, type, isEnum, connector, op, p); } else { Parser<String> p = new StringParser(); ColumnConnector<String> connector = new Db2ColumnConnector<String>(jdbcConnector, schema, table, column, p); Set<Constraint> constraints = connector.getConstraints(); if (constraints.contains(Constraint.UNIQUE) || constraints.contains(Constraint.PRIMARY_KEY)) { throw new UnsupportedTypeException(typeName, Constraint.UNIQUE); } profiler = new PseudoColumnProfiler(schema, table, column, type, isEnum, connector); LOGGER.warn(schema + "." + table + "." + column + " is not supported using pseudo profiler instead!"); } return profiler; }
From source file:hr.fer.spocc.parser.ParseTreeIOUtils.java
private static boolean containsParenthesis(String s, char par) { Set<Integer> escapedIndexes = new HashSet<Integer>(); String unescaped = Escaper.INSTANCE.unescape(s, escapedIndexes); for (int i = 0; i < unescaped.length(); ++i) { char c = unescaped.charAt(i); if (c == par && !escapedIndexes.contains(i)) return true; }//w ww . j a va 2 s . com return false; }
From source file:de.arago.rike.commons.util.ViewHelper.java
public static List<String[]> getAvailableMilestones() { List<String[]> data = new ArrayList<String[]>(); List<Milestone> list = MilestoneHelper.list(); Set<String> releases = new TreeSet<String>(); for (Milestone m : list) { String id = m.getRelease(); if (!id.isEmpty() && !releases.contains(id)) { releases.add(id);// w w w . j av a2 s. c om data.add(new String[] { "release_" + id, "[RELEASE] " + id }); } String dateString = "[?]"; if (m.getDueDate() != null) { SimpleDateFormat f = new SimpleDateFormat("[dd.MM.yyyy] "); dateString = f.format(m.getDueDate()); } data.add(new String[] { "milestone_" + m.getId().toString(), dateString + m.getTitle() }); } return data; }
From source file:com.google.gdt.eclipse.designer.launch.AbstractGwtLaunchConfigurationDelegate.java
/** * GWT requires source folders in classpath (because it has its own compiler), so we should add * all source folders for given project and its required projects. *//*from w w w . j a v a 2s. c o m*/ public static void addSourceFolders(Set<IProject> visitedProjects, List<String> entries, IProject project) throws CoreException { // HACK: see above if (project.getName().endsWith("-design")) { return; } // check for recursion if (visitedProjects.contains(project)) { return; } visitedProjects.add(project); // IJavaProject javaProject = JavaCore.create(project); // add source folders for given project { IPackageFragmentRoot[] packageFragmentRoots = javaProject.getPackageFragmentRoots(); for (int i = 0; i < packageFragmentRoots.length; i++) { IPackageFragmentRoot packageFragmentRoot = packageFragmentRoots[i]; if (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) { entries.add(packageFragmentRoot.getResource().getLocation().toPortableString()); } } } // process required projects { IProject[] referencedProjects = project.getReferencedProjects(); for (int i = 0; i < referencedProjects.length; i++) { IProject referencedProject = referencedProjects[i]; addSourceFolders(visitedProjects, entries, referencedProject); } } }
From source file:com.asakusafw.runtime.stage.output.StageOutputDriver.java
private static void addOutput(Job job, String name, Class<?> formatClass, Class<?> keyClass, Class<?> valueClass) { assert job != null; assert name != null; assert formatClass != null; assert keyClass != null; assert valueClass != null; if (isValidName(name) == false) { throw new IllegalArgumentException(MessageFormat.format("Output name \"{0}\" is not valid", name)); }// ww w. j a v a2s . c o m Configuration conf = job.getConfiguration(); Set<String> names = new TreeSet<>(conf.getStringCollection(K_NAMES)); if (names.contains(name)) { throw new IllegalArgumentException( MessageFormat.format("Output name \"{0}\" is already declared", name)); } names.add(name); conf.setStrings(K_NAMES, names.toArray(new String[names.size()])); conf.setClass(getPropertyName(K_FORMAT_PREFIX, name), formatClass, OutputFormat.class); conf.setClass(getPropertyName(K_KEY_PREFIX, name), keyClass, Object.class); conf.setClass(getPropertyName(K_VALUE_PREFIX, name), valueClass, Object.class); }
From source file:gemlite.core.internal.measurement.MeasureHelper.java
/*** * /***//from w w w .j av a 2 s . c om * 1.??=LogicBean.className $$$ TraceCostBean * 2.LogicBean * Class ****LogicBean$$$TraceCostBean * public long methodName1Cost; * public long methodName2Cost; * * @param cn * @param context * @param className * @param cn * @return */ private final static boolean checkMethodName(ClassNode cn, MethodNode mn, Set<ScannedMethodItem> methods) { ScannedMethodItem check = new ScannedMethodItem(cn.name, mn.name, mn.desc); if (methods != null && methods.contains(check)) return true; if (methods == null) { GemliteAnnotation ga = GemliteHelper.readAnnotations(cn); return ga.getAnnotation(checkPointDesc) != null; } return false; }
From source file:au.org.ala.bhl.WordLists.java
public static LanguageScore detectLanguage(String text, String preferredLanguage) { List<String> words = sanitize(text); // System.err.println(words); String bestLanguage = ""; double bestScore = 0.0; for (String key : _wordLists.keySet()) { Set<String> lexicon = _wordLists.get(key); int match = 0; for (String word : words) { if (lexicon.contains(word.toLowerCase())) { match++;/*from ww w . ja v a2 s . co m*/ } else { // System.err.println(key + " " + word); } } double score = (double) match / (double) words.size(); if (score > bestScore || score == bestScore && key.equalsIgnoreCase(preferredLanguage)) { bestScore = score; bestLanguage = key; } // System.err.println( key + ": " + score); } if (StringUtils.isEmpty(bestLanguage)) { bestLanguage = preferredLanguage; } return new LanguageScore(bestLanguage, bestScore); }
From source file:Main.java
public static void removeInvalidAttributes(Element element, String... validAttributeNames) { Set<String> validNames = new HashSet<String>(); for (String name : validAttributeNames) { validNames.add(name);//from w w w . j a v a2 s . c o m } boolean elementModified = false; NamedNodeMap nnm = element.getAttributes(); for (int i = 0; i < nnm.getLength(); i++) { String attributeName = nnm.item(i).getNodeName(); if (!validNames.contains(attributeName)) { element.removeAttribute(attributeName); elementModified = true; } } if (elementModified) { flagDocumentAsCorrected(element); } }