List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:net.bluewizardhat.yamlcfn.sg.YamlParser.java
@SuppressWarnings("unchecked") private void parseTags(List<Tag> tags, List<Map<String, ?>> values) { log.trace(" Parsing tags: {}", values); values.forEach(m -> { String key = (String) m.get("key"); Object value = m.get("value"); if (value instanceof String) { tags.add(new Tag(key, ValueHolder.of((String) value))); } else if (value instanceof Map) { Map<String, ?> func = (Map<String, String>) value; String fn = (String) func.get("fn"); if (!"join".equals(fn)) { throw new IllegalArgumentException("Unknown function: '" + fn + "'"); }// ww w. j a v a 2 s . co m String delimiter = (String) func.get("delimiter"); List<String> fvalues = (List<String>) func.get("values"); tags.add(new Tag(key, ValueHolder.of(delimiter, fvalues))); } }); }
From source file:com.epam.dlab.backendapi.service.impl.LibraryServiceImpl.java
@Override @SuppressWarnings("unchecked") public List<LibInfoRecord> getLibInfo(String user, String exploratoryName) { Document document = libraryDAO.findAllLibraries(user, exploratoryName); Map<LibKey, List<LibraryStatus>> model = new TreeMap<>(Comparator.comparing(LibKey::getName) .thenComparing(LibKey::getVersion).thenComparing(LibKey::getGroup)); if (document.get(ExploratoryLibDAO.EXPLORATORY_LIBS) != null) { List<Document> exploratoryLibs = (List<Document>) document.get(ExploratoryLibDAO.EXPLORATORY_LIBS); exploratoryLibs.forEach(e -> populateModel(exploratoryName, e, model, "notebook")); }/*from w w w . j a v a 2s .c o m*/ if (document.get(ExploratoryLibDAO.COMPUTATIONAL_LIBS) != null) { Document computationalLibs = getLibsOfActiveComputationalResources(document); populateComputational(computationalLibs, model, "cluster"); } List<LibInfoRecord> libInfoRecords = new ArrayList<>(); for (Map.Entry<LibKey, List<LibraryStatus>> entry : model.entrySet()) { libInfoRecords.add(new LibInfoRecord(entry.getKey(), entry.getValue())); } return libInfoRecords; }
From source file:io.rhiot.spec.Driver.java
@Override public Void call() throws Exception { LOG.info(this + " started"); if (transport != null) { try {//from w w w. j av a 2 s.co m transport.connect(); } catch (Exception e) { LOG.warn("Error connecting driver " + name, e); return null; } } executorService = Executors.newFixedThreadPool(features.size()); List<Future<Void>> results = executorService.invokeAll(features); executorService.shutdown(); executorService.awaitTermination(5, TimeUnit.SECONDS); results.forEach(result -> { try { result.get(); } catch (ExecutionException execution) { LOG.warn("Exception running driver", execution); } catch (Exception interrupted) { } }); if (transport != null) { try { transport.disconnect(); } catch (Exception e) { LOG.warn("Error disconnecting driver " + name, e); } } LOG.info(this + " stopped"); return null; }
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( token -> token.setStopWord(isTokenStopWord(token.getText(), language, stopWordConfig))); }//ww w. j a v a 2 s. c o m } // 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:fi.hsl.parkandride.back.UtilizationDao.java
@TransactionalWrite @Override// ww w. j a va2 s . c o m public void insertUtilizations(List<Utilization> utilizations) { if (utilizations.isEmpty()) { return; } SQLInsertClause insertBatch = queryFactory.insert(qUtilization); utilizations.forEach(u -> { insertBatch.set(qUtilization.facilityId, u.facilityId); insertBatch.set(qUtilization.capacityType, u.capacityType); insertBatch.set(qUtilization.usage, u.usage); insertBatch.set(qUtilization.spacesAvailable, u.spacesAvailable); insertBatch.set(qUtilization.ts, u.timestamp); insertBatch.addBatch(); }); insertBatch.execute(); }
From source file:de.eiswind.magnolia.thymeleaf.processor.CmsProcessorTest.java
@Test public void testInitProcessor() throws Exception { CmsInitElementProcessor cmsInitElementProcessor = new CmsInitElementProcessor(); Element element = new Element("head", "main.html"); element.setAttribute("cms:init", false, ""); List<Node> result = cmsInitElementProcessor.getModifiedChildren(arguments, element, "init"); List<Node> comments = result.stream().filter((node) -> node instanceof Comment) .collect(Collectors.toList()); assertEquals("Expected two comments", 2, comments.size()); comments.forEach((comment) -> Assert.assertTrue("should contain cms:page", ((Comment) comment).getContent().contains("cms:page"))); }
From source file:org.createnet.raptor.auth.service.services.AclManagerService.java
public void setPermissions(Class<?> clazz, Long identifier, UserSid userSid, List<Permission> permissions, Long parentId) {/*from ww w.j a v a 2 s . c o m*/ ObjectIdentity identity = new ObjectIdentityImpl(clazz, identifier); List<Permission> currentPermissions = getPermissionList(userSid.getUser(), identity); currentPermissions.forEach((Permission permission) -> { removePermission(clazz, identifier, userSid, permission); }); addPermissions(clazz, identifier, userSid, permissions, parentId); }
From source file:net.bluewizardhat.yamlcfn.sg.YamlParser.java
@SuppressWarnings("unchecked") public YamlFile parse(InputStream in) throws IOException { List<Map<String, Map<String, ?>>> list = mapper.readValue(in, List.class); list.forEach(line -> { Entry<String, ?> entry = line.entrySet().iterator().next(); switch (entry.getKey()) { case "description": parseDescription(entry.getValue()); break; case "alias": parseAlias((Map<String, ?>) entry.getValue()); break; case "param": parseParam((Map<String, ?>) entry.getValue()); break; case "defaults": parseDefaults((Map<String, ?>) entry.getValue()); break; case "securitygroup": parseSecurityGroup((Map<String, ?>) entry.getValue()); break; default:// w w w . j ava 2 s . c om throw new IllegalArgumentException("Unknown entry '" + entry.getKey() + "'"); } }); return yamlFile; }
From source file:com.hortonworks.streamline.streams.common.event.correlation.EventCorrelationInjector.java
public StreamlineEvent injectCorrelationInformation(StreamlineEvent event, List<StreamlineEvent> parentEvents, String componentName) {//from ww w . jav a2 s .co m Set<String> rootIds = new HashSet<>(); Set<String> parentIds = new HashSet<>(); if (!parentEvents.isEmpty()) { parentEvents.forEach(parentEvent -> { if (EventCorrelationInjector.containsRootIds(parentEvent)) { Set<String> rootIdsForParent = EventCorrelationInjector.getRootIds(parentEvent); if (rootIdsForParent != null && !rootIdsForParent.isEmpty()) { rootIds.addAll(rootIdsForParent); } else { rootIds.add(parentEvent.getId()); } } else { // assume parent event is the root event if it doesn't have correlation information rootIds.add(parentEvent.getId()); } parentIds.add(parentEvent.getId()); }); } // adding correlation and parent events information Map<String, Object> header = new HashMap<>(); header.putAll(event.getHeader()); header.put(HEADER_KEY_ROOT_IDS, rootIds); header.put(HEADER_KEY_PARENT_IDS, parentIds); if (StringUtils.isNotEmpty(componentName)) { header.put(HEADER_KEY_SOURCE_COMPONENT_NAME, componentName); } return StreamlineEventImpl.builder().from(event).header(header).build(); }
From source file:de.ks.file.FileViewController.java
public void addFiles(List<File> additionalFiles) { additionalFiles.removeAll(files);// ww w.j ava 2 s .c o m additionalFiles.forEach(this::addPossibleImage); log.info("Adding addtional files {}", additionalFiles); files.addAll(additionalFiles); if (!additionalFiles.isEmpty()) { Collections.sort(files); Collections.sort(additionalFiles); File lastFile = additionalFiles.get(additionalFiles.size() - 1); fileList.scrollTo(lastFile); fileList.getSelectionModel().clearSelection(); fileList.getSelectionModel().select(lastFile); } }