List of usage examples for java.util Collection forEach
default void forEach(Consumer<? super T> action)
From source file:org.ow2.proactive.workflow_catalog.rest.entity.WorkflowRevision.java
public void addGenericInformation(Collection<GenericInformation> genericInformation) { genericInformation.forEach(gi -> addGenericInformation(gi)); }
From source file:org.obiba.mica.dataset.rest.entity.rql.RQLCriteriaOpalConverter.java
private void parseNodes(Collection<?> args) { args.forEach(arg -> parseNode((ASTNode) arg)); }
From source file:spypunk.tetris.ui.controller.TetrisControllerImpl.java
private void executeTetrisControllerCommands( final Collection<TetrisControllerCommand> tetrisControllerCommands) { if (CollectionUtils.isEmpty(tetrisControllerCommands)) { return;//ww w . j a v a 2 s . c o m } tetrisControllerCommands.forEach(tetrisControllerCommand -> tetrisControllerCommand.execute(tetris)); }
From source file:org.apache.geode.BundledJarsJUnitTest.java
/** * Find all of the jars bundled with the project. Key is the name of the jar, value is the path. *//* w w w . j a v a 2 s.com*/ private TreeMap<String, String> getBundledJars() { File geodeHomeDirectory = new File(GEODE_HOME); assertTrue("Please set the GEODE_HOME environment variable to the product installation directory.", geodeHomeDirectory.isDirectory()); Collection<File> jars = FileUtils.listFiles(geodeHomeDirectory, new String[] { "jar" }, true); TreeMap<String, String> sortedJars = new TreeMap<>(); jars.forEach(jar -> sortedJars.put(jar.getName(), jar.getPath())); Collection<File> wars = FileUtils.listFiles(geodeHomeDirectory, new String[] { "war" }, true); TreeSet<File> sortedWars = new TreeSet<>(wars); sortedWars.stream().flatMap(BundledJarsJUnitTest::extractJarNames) .forEach(jar -> sortedJars.put(jar.getName(), jar.getPath())); sortedJars.keySet().removeIf(s -> s.startsWith("geode")); return sortedJars; }
From source file:org.uberfire.backend.server.plugin.GwtRuntimePluginLoader.java
void loadPlugins() throws IOException { pluginRegistry.removeAll();//from w w w. j av a2 s. c o m final File pluginRoot = new File(pluginDir); if (pluginRoot.exists()) { Collection<File> deployedPlugins = FileUtils.listFiles(pluginRoot, new String[] { "jar" }, false); deployedPlugins.forEach(p -> loadPlugin(Paths.get(p.getAbsolutePath()), false)); } }
From source file:eu.tripledframework.eventstore.infrastructure.ReflectionObjectConstructor.java
@Override public T applyDomainEvents(T instance, Collection<DomainEvent> events) { if (events == null || events.isEmpty()) { return instance; }/*from w ww . ja v a 2 s.c o m*/ events.forEach(event -> applyDomainEvent(instance, event)); invokePostConstructIfNeeded(instance); return instance; }
From source file:com.ikanow.aleph2.storm.samples.topology.JavaScriptTopology2.java
@Override public Tuple2<Object, Map<String, String>> getTopologyAndConfiguration(DataBucketBean bucket, IEnrichmentModuleContext context) { TopologyBuilder builder = new TopologyBuilder(); String contextSignature = context.getEnrichmentContextSignature(Optional.of(bucket), Optional.empty()); builder.setSpout("timer", new TimerSpout(3000L)); JavaScriptProviderBean providerBean = BeanTemplateUtils .from(bucket.streaming_enrichment_topology().config(), JavaScriptProviderBean.class).get(); if (providerBean == null) { providerBean = new JavaScriptProviderBean(); }/*from w ww . j a v a 2 s .c om*/ if (null == providerBean.getGlobalScript()) { providerBean.setGlobalScript( new PropertyBasedScriptProvider("/com/ikanow/aleph2/storm/samples/script/js/scripts.properties") .getGlobalScript()); } BeanBasedScriptProvider mapperScriptProvider = new BeanBasedScriptProvider(providerBean); BeanBasedScriptProvider folderScriptProvider = new BeanBasedScriptProvider(providerBean); final Collection<Tuple2<BaseRichSpout, String>> entry_points = context .getTopologyEntryPoints(BaseRichSpout.class, Optional.of(bucket)); entry_points.forEach(spout_name -> builder.setSpout(spout_name._2(), spout_name._1())); entry_points.stream().reduce( builder.setBolt("mapperBolt", new JavaScriptMapperBolt(contextSignature, mapperScriptProvider)), (acc, v) -> acc.shuffleGrouping(v._2()), (acc1, acc2) -> acc1 // (not possible in practice) ); builder.setBolt("folderBolt", new JavaScriptFolderBolt(contextSignature, folderScriptProvider)) .shuffleGrouping("mapperBolt").shuffleGrouping("timer"); builder.setBolt("out", context.getTopologyStorageEndpoint(BaseRichBolt.class, Optional.of(bucket))) .localOrShuffleGrouping("folderBolt"); return new Tuple2<Object, Map<String, String>>(builder.createTopology(), new HashMap<String, String>()); }
From source file:objenome.solver.evolve.Population.java
public void removeAll(Collection<I> toKill) { individuals.removeAll(toKill); toKill.forEach(this::onRemoved); }
From source file:com.ikanow.aleph2.data_model.utils.TestPropertiesUtils.java
@Test public void test_mergeProperties() throws IOException { final String temp_dir = System.getProperty("java.io.tmpdir") + File.separator; final String conf_dir_str = temp_dir + "test_merge_conf_dir"; final File dir = new File(conf_dir_str); final File default_conf = new File(temp_dir + "default.properties"); default_conf.delete(); assertFalse(default_conf.exists()); FileUtils.forceMkdir(dir);/*from w w w .j a va 2s.co m*/ final Collection<File> conf_files = FileUtils.listFiles(dir, Arrays.asList("conf", "properties", "json").toArray(new String[0]), false); conf_files.forEach(f -> f.delete()); final Collection<File> conf_files_deleted = FileUtils.listFiles(dir, Arrays.asList("conf", "properties", "json").toArray(new String[0]), false); assertTrue(conf_files_deleted.isEmpty()); // Fallback file: FileUtils.write(default_conf, "a=test_1\nb=test2"); final File merge1 = new File(conf_dir_str + File.separator + "a_test.properties"); final File merge2 = new File(conf_dir_str + File.separator + "b_test.properties"); final File merge3 = new File(conf_dir_str + File.separator + "c_test.properties"); FileUtils.write(merge1, "b=test_2.1\nc=test3"); FileUtils.write(merge2, "c=test_3.1\nd=test4"); FileUtils.write(merge3, "d=test_4.1\ne=test5"); final Config conf = PropertiesUtils.getMergedConfig(Optional.of(dir), default_conf); assertEquals(Arrays.asList("a", "b", "c", "d", "e"), conf.root().keySet().stream().sorted().collect(Collectors.toList())); assertEquals("test_1", conf.getString("a")); assertEquals("test_2.1", conf.getString("b")); assertEquals("test_3.1", conf.getString("c")); assertEquals("test_4.1", conf.getString("d")); assertEquals("test5", conf.getString("e")); final Config conf2 = PropertiesUtils.getMergedConfig(Optional.empty(), default_conf); assertEquals(Arrays.asList("a", "b"), conf2.root().keySet().stream().sorted().collect(Collectors.toList())); }
From source file:org.apache.eagle.alert.engine.runner.MapComparator.java
@SuppressWarnings("unchecked") public void compare() { Set<K> keys1 = map1.keySet(); Set<K> keys2 = map2.keySet(); Collection<K> addedKeys = CollectionUtils.subtract(keys1, keys2); Collection<K> removedKeys = CollectionUtils.subtract(keys2, keys1); Collection<K> modifiedKeys = CollectionUtils.intersection(keys1, keys2); addedKeys.forEach(k -> added.add(map1.get(k))); removedKeys.forEach(k -> removed.add(map2.get(k))); modifiedKeys.forEach(k -> {//from ww w . j a va 2 s. c o m if (!map1.get(k).equals(map2.get(k))) { modified.add(map1.get(k)); } }); }