List of usage examples for java.util Collection stream
default Stream<E> stream()
From source file:ch.sdi.report.SdiReporter.java
private void appendPersonList(StringBuilder aSb, Collection<?> list) { list.stream().filter(p -> p instanceof Person).map(p -> Person.class.cast(p)) .forEach(p -> appendSimplePerson(aSb, p)); }
From source file:com.hortonworks.registries.schemaregistry.HAServerNotificationManager.java
public void refreshServerInfo(Collection<HostConfigStorable> hostConfigStorableList) { if (hostConfigStorableList != null) { synchronized (UPDATE_ITERATE_LOCK) { hostIps.clear();//from w w w . j av a 2 s . co m hostConfigStorableList.stream() .filter(hostConfigStorable -> !hostConfigStorable.getHostUrl().equals(serverUrl)) .forEach(hostConfig -> { hostIps.add(hostConfig.getHostUrl()); }); } } }
From source file:ch.sdi.report.SdiReporter.java
/** * @param aSb//w w w . j a va 2 s. co m * @param aList * @return */ private void appendDatasetList(StringBuilder aSb, Collection<?> aList) { aList.stream().filter(p -> p instanceof Dataset).map(p -> Dataset.class.cast(p)) .forEach(p -> appendDataset(aSb, p)); }
From source file:guru.qas.martini.DefaultMixologist.java
protected StepImplementation getImplementation(Recipe recipe, gherkin.ast.Step step, Collection<StepImplementation> implementations) { List<StepImplementation> matches = implementations.stream().filter(i -> i.isMatch(step)) .collect(Collectors.toList()); StepImplementation match;// w w w .jav a 2 s . c om int count = matches.size(); if (1 == count) { match = matches.get(0); } else if (count > 1) { throw new AmbiguousStepException.Builder().setStep(step).setMatches(matches).build(); } else if (unimplementedStepsFatal) { throw new UnimplementedStepException.Builder().setRecipe(recipe).setStep(step).build(); } else { match = getUnimplemented(step); } return match; }
From source file:com.nagarro.core.util.ws.impl.AddonAwareMessageSource.java
/** * Maps each element of <b>addonsPath</b> to valid message bundle path. Result collection is also filtered to remove * empty, invalid and duplicated entries. * * @param addonsPath//from w ww. j av a2s .c o m * paths to transform * @param basePath * from where result path should start * @return collection of paths to message bundles */ protected Collection<String> mapAddonLocation(final Collection<String> addonsPath, final String basePath) { return addonsPath.stream().map(p -> formatPath(p, basePath)).filter(StringUtils::isNotBlank) .collect(Collectors.toSet()); }
From source file:eu.tripledframework.eventstore.infrastructure.ReflectionObjectConstructor.java
@Override public T construct(Collection<DomainEvent> events) { if (events == null || events.isEmpty()) { return null; }/*from ww w .ja va 2 s . c om*/ DomainEvent firstEvent = events.stream().findFirst().get(); T instance = createInstance(firstEvent); LOGGER.debug("Created new {} with event {}", instance.getClass().getSimpleName(), firstEvent); events.stream().skip(1).forEach(p -> applyDomainEvent(instance, p)); invokePostConstructIfNeeded(instance); return instance; }
From source file:com.epam.reportportal.extension.bugtracking.tfs.DescriptionBuilder.java
@Override public String build(WorkItem workItem, InternalTicket ticket, Collection<String> values) { Map<String, Object> templateContext = new HashMap<>(); /* What is description? */ templateContext.put("description", values.stream().collect(Collectors.joining("<br>"))); if ((null != ticket.getComments()) && (!ticket.getComments().trim().isEmpty())) { templateContext.put("comments", ticket.getComments()); }/* ww w. jav a 2 s. c o m*/ if (null != ticket.getBackLinks()) { templateContext.put("backLinks", ticket.getBackLinks()); } if (null != ticket.getLogs()) { /* Order of log items is important */ List<HtmlLogEntry> logData = new LinkedList<>(); for (InternalTicket.LogEntry log : ticket.getLogs()) { String attachmentUrl = null; if (null != log.getAttachment()) { Attachment attachment = new AttachmentImpl(createFile(log), log.getLog().getLogMsg()); workItem.getAttachments().add(attachment); /* need to save to obtain attachment URL */ TfsUtils.saveWorkItem(workItem); attachmentUrl = attachment.getURL().toString(); } String message = log.getIncludeLogs() ? log.getLog().getLogMsg() : ""; String screen = Strings.isNullOrEmpty(attachmentUrl) ? null : attachmentUrl; boolean isLogs = log.getIncludeLogs(); HtmlLogEntry entry = new HtmlLogEntry(message, screen, isLogs); logData.add(entry); } templateContext.put("logs", logData); } return templateEngine.merge(TFS_BUG_TEMPLATE_PATH, templateContext); }
From source file:com.epam.ta.reportportal.auth.UserRoleHierarchy.java
@Override public Collection<? extends GrantedAuthority> getReachableGrantedAuthorities( Collection<? extends GrantedAuthority> authorities) { if ((authorities == null) || (authorities.isEmpty())) { return AuthorityUtils.NO_AUTHORITIES; }/*from ww w . ja v a2 s.c om*/ List<GrantedAuthority> reachableRoles = authorities.stream() .filter(authority -> authoritiesMap.containsKey(authority)) .flatMap(authority -> authoritiesMap.get(authority).stream()).collect(Collectors.toList()); if (logger.isDebugEnabled()) { logger.debug("getReachableGrantedAuthorities() - From the roles " + authorities + " one can reach " + reachableRoles + " in zero or more steps."); } return reachableRoles; }
From source file:org.obiba.mica.web.model.StudySummaryDtos.java
List<Mica.StudySummaryDto> asDtos(Collection<String> studyIds) { return studyIds.stream().map(this::asDto).collect(Collectors.toList()); }
From source file:eu.java.pg.jsonb.types.JSONBUserType.java
@SuppressWarnings("unchecked") @Override//from w w w .j a v a 2s .c om public Object deepCopy(Object value) throws HibernateException { if (!(value instanceof Collection)) { return value; } Collection<?> collection = (Collection) value; Collection collectionClone = CollectionFactory.newInstance(collection.getClass()); collectionClone.addAll(collection.stream().map(this::deepCopy).collect(Collectors.toList())); return collectionClone; }