List of usage examples for java.util Set forEach
default void forEach(Consumer<? super T> action)
From source file:org.talend.dataprep.transformation.aggregation.operation.Average.java
@Override public void normalize(AggregationResult result) { // Remove from result all entries with NaN as average. Set<String> entryToRemove = result.entries().stream() .filter(entry -> Double.isNaN(entry.getValue().getValue())).map(Map.Entry::getKey) .collect(Collectors.toSet()); entryToRemove.forEach(result::remove); }
From source file:fr.ortolang.diffusion.membership.entity.Profile.java
public void setPublicKeys(Set<String> keys) { keys.forEach(this::addPublicKey); }
From source file:ai.grakn.test.engine.tasks.storage.TaskStateInMemoryStoreTest.java
@Test public void testTaskPagination() { for (int i = 0; i < 20; i++) { stateStorage.newState(task());//from w w w. jav a2 s .c o m } Set<TaskState> setA = stateStorage.getTasks(null, null, null, null, 10, 0); Set<TaskState> setB = stateStorage.getTasks(null, null, null, null, 10, 10); setA.forEach(x -> assertFalse(setB.contains(x))); }
From source file:org.matonto.sparql.rest.impl.SparqlRestImplTest.java
@Test public void getPagedResultsWithLinksTest() { Response response = target().path("sparql/page").queryParam("query", ALL_QUERY).queryParam("limit", 1) .queryParam("offset", 1).request().get(); assertEquals(response.getStatus(), 200); MultivaluedMap<String, Object> headers = response.getHeaders(); assertEquals(headers.get("X-Total-Count").get(0), "" + testModel.size()); Set<Link> links = response.getLinks(); assertEquals(links.size(), 2);//from w ww.j a va 2 s. co m links.forEach(link -> { assertTrue(link.getUri().getRawPath().contains("sparql/page")); assertTrue(link.getRel().equals("prev") || link.getRel().equals("next")); }); try { JSONObject result = JSONObject.fromObject(response.readEntity(String.class)); assertTrue(result.containsKey("bindings")); assertTrue(result.containsKey("data")); JSONArray data = result.getJSONArray("data"); assertEquals(data.size(), 1); } catch (Exception e) { fail("Expected no exception, but got: " + e.getMessage()); } }
From source file:com.flipkart.flux.client.utils.TestHttpServer.java
@Inject public TestHttpServer(Set<TestResource> testResourceSet) { ObjectMapper objectMapper = new ObjectMapper(); JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(objectMapper);/*from w w w . ja va 2 s . com*/ this.testResourceMap = new HashMap<>(); testResourceSet.forEach((tr) -> this.testResourceMap.put(tr.getClass(), tr)); final ResourceConfig resourceConfig = new ResourceConfig(); this.testResourceMap.values().forEach(resourceConfig::register); resourceConfig.register(provider); httpServer = JettyHttpContainerFactory.createServer( UriBuilder.fromUri("http://localhost/").port(TEST_HTTP_SERVER_PORT).build(), resourceConfig); }
From source file:org.commonjava.indy.core.inject.IspnNotFoundCache.java
@Override public void clearMissing(final Location location) { nfcCache.execute((cache) -> {// ww w .j ava 2 s . co m Set<String> paths = getMissing(location); paths.forEach(path -> cache.remove(getResourceKey(new ConcreteResource(location, path)))); return null; }); }
From source file:org.onosproject.vpls.IntentInstaller.java
/** * Formats the requests for creating and submit intents. * Single Points to Multi Point intents are created for all the configured * Connect Points. Multi Point to Single Point intents are created for * Connect Points configured that have hosts attached. * * @param confHostPresentCPoint A map of Connect Points with the eventual * MAC address of the host attached, by VLAN *///from w ww. j a v a2 s.c o m protected void installIntents(SetMultimap<VlanId, Pair<ConnectPoint, MacAddress>> confHostPresentCPoint) { List<Intent> intents = new ArrayList<>(); confHostPresentCPoint.keySet().stream().filter(vlanId -> confHostPresentCPoint.get(vlanId) != null) .forEach(vlanId -> { Set<Pair<ConnectPoint, MacAddress>> cPoints = confHostPresentCPoint.get(vlanId); cPoints.forEach(cPoint -> { MacAddress mac = cPoint.getValue(); ConnectPoint src = cPoint.getKey(); Set<ConnectPoint> dsts = cPoints.stream().map(Pair::getKey).filter(cp -> !cp.equals(src)) .collect(Collectors.toSet()); Key brcKey = buildKey(PREFIX_BROADCAST, src, vlanId); if (intentService.getIntent(brcKey) == null && dsts.size() > 0) { intents.add(buildBrcIntent(brcKey, src, dsts, vlanId)); } if (mac != null && countMacInCPoints(cPoints) > 1 && dsts.size() > 0) { Key uniKey = buildKey(PREFIX_UNICAST, src, vlanId); if (intentService.getIntent(uniKey) == null) { MultiPointToSinglePointIntent uniIntent = buildUniIntent(uniKey, dsts, src, vlanId, mac); intents.add(uniIntent); } } }); }); submitIntents(intents); }
From source file:co.com.carpco.altablero.hibernate.bll.YearBll.java
private void initializeCache() { CachingProvider cachingProvider = Caching.getCachingProvider(); CacheManager cacheManager = cachingProvider.getCacheManager(); MutableConfiguration<Integer, Set> config = new MutableConfiguration<Integer, Set>() .setTypes(Integer.class, Set.class).setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_DAY)) .setWriteThrough(true).setReadThrough(true) .setCacheLoaderFactory(new Factory<CacheLoader<Integer, Set>>() { @Override//from www. j av a2s . c o m public CacheLoader<Integer, Set> create() { return new CacheLoader<Integer, Set>() { @Override public Set load(Integer key) throws CacheLoaderException { final Set<YearBO> yearBOSet = new HashSet<>(); Set<BzYear> bzYearSet = yearDao.getYearSet(); if (bzYearSet != null && bzYearSet.size() > 0) { bzYearSet.forEach((BzYear bzYear) -> yearBOSet.add(new YearBO(bzYear))); } return yearBOSet; } @Override public Map<Integer, Set> loadAll(Iterable<? extends Integer> itrbl) throws CacheLoaderException { Map<Integer, Set> answer = new HashMap<>(); itrbl.forEach((Integer k) -> answer.put(k, load(k))); return answer; } }; } }).setCacheWriterFactory(new Factory<CacheWriter<Integer, Set>>() { @Override public CacheWriter<Integer, Set> create() { CacheWriter<Integer, Set> writer = new CacheWriter<Integer, Set>() { @Override public void write(Cache.Entry<? extends Integer, ? extends Set> entry) throws CacheWriterException { } @Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends Set>> clctn) throws CacheWriterException { } @Override public void delete(Object o) throws CacheWriterException { } @Override public void deleteAll(Collection<?> clctn) throws CacheWriterException { } }; return writer; } }).setStatisticsEnabled(true); cache = cacheManager.createCache("yearCache", config); config.isReadThrough(); }
From source file:com.github.frapontillo.pulse.crowd.remstopword.simple.SimpleStopWordRemover.java
@Override protected void processMessage(Message message, StopWordConfig stopWordConfig) { String language = message.getLanguage(); // for each element, reset the "stop word" property // by looking up the word in the proper dictionary // mark tokens if (stopWordConfig.mustStopTokens()) { List<Token> tokens = message.getTokens(); if (tokens != null) { tokens.forEach(/*from ww w. j a v a2s. com*/ token -> token.setStopWord(isTokenStopWord(token.getText(), language, stopWordConfig))); } } // mark tags if (stopWordConfig.mustStopTags()) { Set<Tag> tags = message.getTags(); if (tags != null) { tags.forEach(tag -> { tag.setStopWord(isTagStopWord(tag.getText(), language, stopWordConfig)); // for each tag, mark its categories if (stopWordConfig.mustStopCategories()) { Set<Category> categories = tag.getCategories(); if (categories != null) { categories.forEach(cat -> cat .setStopWord(isCategoryStopWord(cat.getText(), language, stopWordConfig))); } } }); } } }
From source file:com.openthinks.webscheduler.model.security.User.java
public void setRoles(Set<Role> roles) { this.roles = roles; if (roles != null) { RoleKeys roleKeys = new RoleKeys(); roles.forEach((role) -> { RoleKey key = new RoleKey(); key.setId(role.getId());//from w w w .j ava 2 s. c o m key.setName(role.getName()); roleKeys.add(key); }); setRoleKeys(roleKeys); } }