List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.diag.CasDoctor.java
public boolean analyze(CAS aCas) { List<LogMessage> messages = new ArrayList<>(); boolean result = analyze(aCas, messages); if (log.isDebugEnabled()) { messages.forEach(s -> log.debug(s)); }/*from w w w .j a v a 2 s . c o m*/ return result; }
From source file:com.ftb2om2.util.Zipper.java
public void createOSZ(String mp3Path, String outputPath, List<Difficulty> difficulty) throws IOException { FileOutputStream fos = new FileOutputStream( outputPath + "\\" + FilenameUtils.getBaseName(mp3Path) + ".osz"); ZipOutputStream zos = new ZipOutputStream(fos); addToZip(mp3Path, "Audio.mp3", zos); difficulty.forEach(file -> { try {/*from www.j av a 2s . com*/ addToZip(outputPath + "\\" + file.getDifficultyName() + ".osu", file.getDifficultyName() + ".osu", zos); } catch (IOException ex) { throw new UncheckedIOException(ex); } }); zos.close(); fos.close(); }
From source file:org.fenixedu.academic.thesis.ui.service.ExportThesisProposalsService.java
private void fillSpreadSheet(List<ThesisProposal> thesisProposals, final Spreadsheet spreadsheet, List<Set<StudentThesisCandidacy>> studentCandidacies, int maxParticipants) { thesisProposals.forEach(p -> { fillProposalInfo(p, spreadsheet, maxParticipants); studentCandidacies.add(p.getStudentThesisCandidacySet()); });//from w w w. ja va 2 s. c o m }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.diag.CasDoctor.java
public void repair(CAS aCas) { List<LogMessage> messages = new ArrayList<>(); repair(aCas, messages);//from w ww .j a va 2 s .c o m if (log.isWarnEnabled() && !messages.isEmpty()) { messages.forEach(s -> log.warn(s)); } }
From source file:de.knoplab.todomaven.plugins.DefaultLoadPlugin.java
@Override public void execute() { mapper = new ObjectMapper(); try {// w w w.jav a 2 s .co m List<TodoTask> listOutput; TypeFactory typeFactory = TypeFactory.defaultInstance(); listOutput = mapper.readValue(new File("./src/main/resources/json/saveTasks.json"), typeFactory.constructCollectionType(ArrayList.class, DefaultTodoTask.class)); listOutput.forEach(e -> dataTaskService.addNewTask(e)); } catch (IOException ex) { AlertWindow.display("Error data", "Any saved data"); Logger.getLogger(DefaultLoadPlugin.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.sandbox.recipe.service.RecipeController.java
@CrossOrigin @RequestMapping("/findMostViewed") public List<Recipe> findMostViewed(@RequestBody Long count) { System.out.println("findMostViewed() count = " + count); List<Recipe> recipes = new ArrayList<>(); List<Object[]> mostViewed = _historyItemRepository.findMostViewed(count); if (CollectionUtils.isNotEmpty(mostViewed)) { mostViewed.forEach((obj) -> { // findAll(List<Long>) does _not_ maintain the order of the list of ids // _recipeRepository.findAll(recipeIds).forEach((temp) -> recipes.add(temp)); recipes.add(_recipeRepository.findOne(((BigInteger) obj[0]).longValue())); });// w w w . java 2 s .com } System.out.println("findMostViewed() recipes.size() = " + recipes.size()); return recipes; }
From source file:com.ethlo.kfka.mysql.MysqlKfkaMapStore.java
@Override public Map<Long, T> loadAll(Collection<Long> keys) { logger.debug("Loading data for keys {}", StringUtils.collectionToCommaDelimitedString(keys)); final List<T> res = tpl.query("SELECT * FROM kfka WHERE id IN (:keys)", Collections.singletonMap("keys", keys), mapper); final Map<Long, T> retVal = new HashMap<>(keys.size()); res.forEach(e -> { retVal.put(e.getId(), e);/*from w ww .ja v a 2 s . c o m*/ }); return retVal; }
From source file:org.thingsplode.synapse.serializers.jackson.JacksonSerializer.java
private void registerHandlers(List<JsonSerializer> serializers, HashMap<Class, JsonDeserializer> deSerializers) { if (serializers != null && !serializers.isEmpty()) { serializers.forEach(s -> module.addSerializer(s)); }/* ww w . j a va 2 s. c o m*/ if (deSerializers != null && !deSerializers.isEmpty()) { deSerializers.forEach((k, v) -> module.addDeserializer(k, v)); } }
From source file:com.netflix.genie.agent.cli.ExecCommand.java
@Override public ExitCode run() { for (final sun.misc.Signal s : signalsToIntercept) { sun.misc.Signal.handle(s, signal -> handleTerminationSignal()); }/*from w w w. j a v a 2s . c om*/ log.info("Running job state machine"); stateMachine.start(); final States finalstate; try { finalstate = stateMachine.waitForStop(); } catch (final Exception e) { log.warn("Job state machine execution failed", e); throw new RuntimeException("Job execution error", e); } if (!States.END.equals(finalstate)) { throw new RuntimeException("Job execution failed (final state: " + finalstate + ")"); } if (executionContext.hasStateActionError()) { final List<Triple<States, Class<? extends Action>, Exception>> actionErrors = executionContext .getStateActionErrors(); actionErrors.forEach(triple -> log.error("Action {} in state {} failed with {}: {}", triple.getMiddle().getSimpleName(), triple.getLeft(), triple.getRight().getClass().getSimpleName(), triple.getRight().getMessage())); final Exception firstActionErrorException = actionErrors.get(0).getRight(); throw new RuntimeException("Job execution error", firstActionErrorException); } final JobStatus finalJobStatus = executionContext.getFinalJobStatus().get(); if (finalJobStatus == null) { throw new RuntimeException("Unknown final job status"); } else if (!finalJobStatus.isFinished()) { throw new RuntimeException("Non-final job status post-execution: " + finalJobStatus.name()); } final ExitCode exitCode; switch (finalJobStatus) { case SUCCEEDED: log.info("Job execution completed successfully"); exitCode = ExitCode.SUCCESS; break; case KILLED: log.info("Job execution killed by user"); exitCode = ExitCode.EXEC_ABORTED; break; case FAILED: log.info("Job execution failed"); exitCode = ExitCode.EXEC_FAIL; break; default: throw new RuntimeException("Unexpected final job status: " + finalJobStatus.name()); } return exitCode; }
From source file:io.spring.initializr.web.ui.UiController.java
@RequestMapping(value = "/ui/dependencies", produces = "application/json") public ResponseEntity<String> dependencies(@RequestParam(required = false) String version) { List<DependencyGroup> dependencyGroups = metadataProvider.get().getDependencies().getContent(); List<DependencyItem> content = new ArrayList<>(); Version v = StringUtils.isEmpty(version) ? null : Version.parse(version); dependencyGroups.forEach(g -> g.getContent().forEach(d -> { if (v != null && d.getVersionRange() != null) { if (d.match(v)) { content.add(new DependencyItem(g.getName(), d)); }//from w w w. j a v a 2 s . co m } else { content.add(new DependencyItem(g.getName(), d)); } })); String json = writeDependencies(content); return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).eTag(createUniqueId(json)).body(json); }