List of usage examples for java.util Collection forEach
default void forEach(Consumer<? super T> action)
From source file:org.pdfsam.ui.module.OpenButton.java
public void initModules(Collection<Module> modules) { modules.forEach(m -> { if (m.descriptor().hasInputType(outputType)) { getItems().add(new OpenWithMenuItem(m)); }/*from w w w. j a v a 2s . c om*/ }); }
From source file:org.jmingo.document.id.IdFieldGenerator.java
private void generateIdForList(Collection<?> objects) { objects.forEach(this::generateId); }
From source file:org.trustedanalytics.servicecatalog.service.ApplicationsService.java
/** * @param space unique space identifier//from www .java 2 s.c o m * @return applications within space */ public Collection<CcApp> getSpaceApps(UUID space) { Collection<CcApp> apps = ccOperations.getSpaceSummary(space).getApps(); apps.forEach(this::fixAppInfo); return apps; }
From source file:org.homiefund.test.dao.DebtPreviewDAOTest.java
@Test public void getTransactionsForPreview() { Collection<DebtPreview> list = debtPreviewDAO.getTransactionsForPreview(homeDAO.getById(1L)); Assert.assertEquals(18, list.size()); list.forEach(dp -> { Assert.assertEquals(Long.valueOf(1L), dp.getHome()); });/*from w ww . ja v a2s .c om*/ }
From source file:com.github.horrorho.inflatabledonkey.args.PropertyLoader.java
public void help(Collection<? extends Option> optionList) { Options options = new Options(); optionList.forEach(options::addOption); HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setOptionComparator(null); helpFormatter.printHelp(/*w w w .ja va2 s . co m*/ Property.APP_NAME.value().orElse("") + " [OPTION]... (<token> | <appleid> <password>) ", options); }
From source file:org.pdfsam.ui.selection.multiple.SelectionChangedEvent.java
private SelectionChangedEvent(Collection<? extends Integer> selected) { requireNotNull(selected, "Input selection cannot be null"); selected.forEach((i) -> { bottom = Math.max(i, bottom); top = Math.min(i, top);//from w ww . j a v a2 s . c o m }); }
From source file:io.mandrel.endpoints.web.DataController.java
@RequestMapping(value = "/spiders/{id}/data/{extractor}", method = RequestMethod.POST) @ResponseBody//w w w .ja va 2 s. c o m public PageResponse data(@PathVariable Long id, @PathVariable String extractor, PageRequest request, Model model) { Spider spider = spiderService.get(id); DocumentStore theStore = DocumentStores.get(id, extractor).orElseThrow(() -> new NotFoundException("")); if (!theStore.isNavigable()) { throw new NotImplementedException("Not a navigable document store"); } NavigableDocumentStore store = (NavigableDocumentStore) theStore; DataExtractor theExtractor = spider.getExtractors().getData().stream() .filter(ex -> extractor.equals(ex.name())).findFirst().orElseThrow(() -> new NotFoundException("")); if (theExtractor instanceof DefaultDataExtractor) { throw new NotImplementedException("Not a default data extractor"); } Collection<Document> page = store.byPages(request.getLength(), request.getStart() / request.getLength()); page.forEach(doc -> ((DefaultDataExtractor) theExtractor).getFields() .forEach(f -> doc.putIfAbsent(f.getName(), Collections.emptyList()))); Long total = store.total(); PageResponse dataPage = PageResponse.of(page); dataPage.setDraw(request.getDraw()); dataPage.setRecordsTotal(total); dataPage.setRecordsFiltered(total); return dataPage; }
From source file:org.age.console.Console.java
public void mainLoop() throws IOException { String line;// www .ja va 2 s .co m while ((line = reader.readLine()) != null) { log.debug("Read command: {}.", line); try { // We need to allocate new instances every time final MainCommand mainCommand = new MainCommand(); final JCommander mainCommander = new JCommander(mainCommand); final Collection<Command> commands = applicationContext.getBeansOfType(Command.class).values(); commands.forEach(mainCommander::addCommand); mainCommander.parse(WHITESPACE.split(line)); final String parsedCommand = mainCommander.getParsedCommand(); final Command command; final JCommander commander; if (isNull(parsedCommand)) { commander = mainCommander; command = mainCommand; } else { commander = mainCommander.getCommands().get(parsedCommand); command = (Command) Iterables.getOnlyElement(commander.getObjects()); } if (!command.execute(commander, reader, printWriter)) { break; } } catch (final ParameterException e) { log.error("Incorrect command.", e); printWriter.println("Incorrect command." + e.getMessage()); } } }
From source file:com.ikanow.aleph2.storm.samples.topology.SampleStormStreamTopology1.java
@Override public Tuple2<Object, Map<String, String>> getTopologyAndConfiguration(final DataBucketBean bucket, final IEnrichmentModuleContext context) { final TopologyBuilder builder = new TopologyBuilder(); 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("sample_conversion_bolt", new SampleConversionBolt()), (acc, v) -> acc.localOrShuffleGrouping(v._2()), (acc1, acc2) -> acc1 // (not possible in practice) );//from w w w. j a v a2s . c o m builder.setBolt("sample_enrichment_bolt", new SampleEnrichmentBolt()) .localOrShuffleGrouping("sample_conversion_bolt"); builder.setBolt("default_aleph2_output_spout", context.getTopologyStorageEndpoint(BaseRichBolt.class, Optional.of(bucket))) .localOrShuffleGrouping("sample_enrichment_bolt"); return Tuples._2T(builder.createTopology(), Collections.emptyMap()); }
From source file:com.ikanow.aleph2.storm.samples.topology.JavaScriptTopology.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()); 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(// w w w . j a va 2 s . c om builder.setBolt("scriptBolt", new JavaScriptBolt(contextSignature, "/com/ikanow/aleph2/storm/samples/script/js/scripts.properties")), (acc, v) -> acc.shuffleGrouping(v._2()), (acc1, acc2) -> acc1 // (not possible in practice) ); builder.setBolt("reducerCounter", new ReducerCounterBolt()).shuffleGrouping("scriptBolt"); builder.setBolt("out", context.getTopologyStorageEndpoint(BaseRichBolt.class, Optional.of(bucket))) .localOrShuffleGrouping("reducerCounter"); return new Tuple2<Object, Map<String, String>>(builder.createTopology(), new HashMap<String, String>()); }