List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:org.fornax.cartridges.sculptor.smartclient.server.util.ServiceContextFactoryForSpring.java
@Override protected Set<String> rolesFromSubject(Subject subject) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); HashSet<String> roles = new HashSet<String>(); GrantedAuthority[] authorities = auth.getAuthorities(); for (GrantedAuthority grantedAuthority : authorities) { roles.add(grantedAuthority.getAuthority()); }/*from w w w . jav a2s . com*/ return roles; }
From source file:test.TestPredImpl.java
@Test(groups = "{predicate}") public void testOne() { PredicateEstimator.Source source = PredicateEstimator.Source.CRM; System.out.println("source " + source.name()); DataMap map = new DataMap(); map.populateMap();//from w w w . jav a 2 s . c o m PredicateEstimator predicateEstimator = new PredicateEstimator(map); double rate = predicateEstimator.runEstimate(" foods = 1 or other = 2 "); //double rate = predicateEstimator.runEstimate(" (((gender = \"male\" or foods = \"1.1\")))"); //double rate = predicateEstimator.runEstimate("( foods = 1 and other = 2) and gender = \"male\" and not age = \"25-34\" "); // foods.1.1 //String sce = predicateEstimator.getSourceStack().pop().getValue() ; double ncs = predicateEstimator.getPopulation(); double value = Math.abs(Math.round(ncs * rate)); System.out.println("result of dr " + rate + " total " + value + " ncs " + ncs); //predicateEstimator Address address = new Address(new Street(4813, "corsica dr"), 90630, "cypress"); Set<Short> setShort = new HashSet<Short>(); setShort.add((short) 1); setShort.add((short) 2); setShort.add((short) 3); Person person = new Person("mickey", 30, 4000.00, true, address); person.setSetShort(setShort); String q = "exist(setShort, 1) "; PredicateVisitorImpl impl2 = new PredicateVisitorImpl(q); boolean r2 = impl2.runPredicate(person); System.out.println("result of r2 " + r2); Assert.assertEquals(r2, true); HashSet<String> set = new HashSet<String>(); set.add("t1"); set.add("t2"); set.add("t3"); address.setSet(set); String query1 = "exist(set, \"t1\") "; PredicateVisitorImpl impl1 = new PredicateVisitorImpl(query1); boolean r1 = impl1.runPredicate(address); System.out.println("result of r " + r1); Assert.assertEquals(r2, true); String query = " age > 10 and income < 40.00 and male = true "; PredicateVisitorImpl impl = new PredicateVisitorImpl(query); boolean r = impl.runPredicate(person); System.out.println("result of r " + r); }
From source file:com.thoughtworks.go.server.materials.postcommit.svn.SvnPostCommitHookImplementer.java
HashMap<String, String> createUrlToRemoteUUIDMap(Set<Material> materials) { final HashSet<SvnMaterial> setOfSvnMaterials = new HashSet<>(); for (Material material : materials) { if (material instanceof SvnMaterial) { setOfSvnMaterials.add((SvnMaterial) material); }// ww w.ja va2 s . c o m } return getEmptySvnCommand().createUrlToRemoteUUIDMap(setOfSvnMaterials); }
From source file:de.kaiserpfalzEdv.office.contacts.contact.ContactDO.java
@SuppressWarnings("deprecation") public void setAddresses(@NotNull final Collection<? extends Address> addresses) { HashSet<AddressDO> addressDOs = new HashSet<>(addresses.size()); addresses.parallelStream().forEach(a -> addressDOs.add((AddressDO) a)); setAddresses(addressDOs);//from w w w . j ava 2 s.c om }
From source file:de.kaiserpfalzEdv.office.contacts.contact.ContactDO.java
@SuppressWarnings("deprecation") public void setSubContacts(@NotNull final Collection<? extends Contact> contacts) { HashSet<ContactDO> contactDOs = new HashSet<>(contacts.size()); contactDOs.parallelStream().forEach(c -> contactDOs.add((ContactDO) c)); setSubContacts(contactDOs);// ww w . j a v a 2 s . c om }
From source file:com.datatorrent.lib.io.fs.AbstractFSDirectoryInputOperatorFailureHandlingTest.java
@Test public void testFailureHandling() throws Exception { FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true); HashSet<String> allLines = Sets.newHashSet(); // Create files with 100 records. for (int file = 0; file < 10; file++) { HashSet<String> lines = Sets.newHashSet(); for (int line = 0; line < 10; line++) { lines.add("f" + file + "l" + line); }/*from w ww . j a v a2 s . com*/ allLines.addAll(lines); FileUtils.write(new File(testMeta.dir, "file" + file), StringUtils.join(lines, '\n')); } Thread.sleep(10); TestFSDirectoryInputOperator oper = new TestFSDirectoryInputOperator(); CollectorTestSink<String> queryResults = new CollectorTestSink<String>(); @SuppressWarnings({ "unchecked", "rawtypes" }) CollectorTestSink<Object> sink = (CollectorTestSink) queryResults; oper.output.setSink(sink); oper.setDirectory(testMeta.dir); oper.getScanner().setFilePatternRegexp(".*file[\\d]"); oper.setup(null); for (long wid = 0; wid < 1000; wid++) { oper.beginWindow(wid); oper.emitTuples(); oper.endWindow(); } oper.teardown(); Assert.assertEquals("number tuples", 100, queryResults.collectedTuples.size()); Assert.assertEquals("lines", allLines, new HashSet<String>(queryResults.collectedTuples)); }
From source file:DualKeyHashMap.java
public Set<XKEY> getXKeySet() { HashSet<XKEY> xKeys = new HashSet<XKEY>(); for (DualKey<XKEY, YKEY> key : keySet()) xKeys.add(key.getXKey()); return xKeys; }
From source file:DualKeyHashMap.java
public Set<YKEY> getYKeySet() { HashSet<YKEY> yKeys = new HashSet<YKEY>(); for (DualKey<XKEY, YKEY> key : keySet()) yKeys.add(key.getYKey()); return yKeys; }
From source file:com.termmed.utils.FileHelper.java
public static HashSet<String> getFilesFromFolderWithPattern(String folder, String patternType, String mustHave, String doesntMustHave, boolean isPrevious, boolean isReduced) throws IOException, Exception { HashSet<String> result = null; File dir = new File(folder); HashSet<String> files = new HashSet<String>(); findAllFiles(dir, files, mustHave, doesntMustHave, isPrevious); for (String file : files) { String pattern = getFileTypeByHeader(new File(file), isReduced); if (pattern == null) { log.info("null pattern for file:" + file); continue; }//w w w .j a va2 s. c o m if (pattern.equals(patternType)) { if (result == null) { result = new HashSet<String>(); } result.add(file); } } return result; }
From source file:com.appunite.socketio.SocketIOBase.java
private ImmutableSet<String> getTypesFromString(String str) throws WrongSocketIOResponse { StringTokenizer st = new StringTokenizer(str, ","); HashSet<String> types = new HashSet<String>(); while (st.hasMoreTokens()) { types.add(st.nextToken()); }/*from ww w. j av a 2 s . c o m*/ if (types.isEmpty()) throw new WrongSocketIOResponse("No transport types in socket response"); return ImmutableSet.copyOf(types); }