List of usage examples for java.util Collection stream
default Stream<E> stream()
From source file:org.eclipse.packagedrone.repo.channel.web.channel.ChannelController.java
private static String joinChannelNames(final Collection<String> names) { return names.stream().collect(Collectors.joining("\n")); }
From source file:com.ejisto.modules.dao.local.LocalMockedFieldsDao.java
private Optional<MockedFieldContainer> getSingleField(Collection<MockedFieldContainer> fields, String fieldName) {/* ww w . j ava 2 s . co m*/ return fields.stream().filter(f -> f.getFieldName().equals(fieldName)).findFirst(); }
From source file:com.querydsl.webhooks.GithubReviewWindow.java
@Bean public PullRequestHandler reviewWindowHandler(Environment environment) { Duration defaultReviewWindow = Duration.parse(environment.getRequiredProperty("duration")); //duration is the default window Map<String, ScheduledFuture<?>> asyncTasks = Maps.newConcurrentMap(); return payload -> { PullRequest pullRequest = payload.getPullRequest(); Ref head = pullRequest.getHead(); try {// w w w .j a v a 2 s . co m GHRepository repository = github.getRepository(payload.getRepository().getFullName()); Collection<GHLabel> labels = repository.getIssue(pullRequest.getNumber()).getLabels(); Duration reviewTime = labels.stream().map(label -> "duration." + label.getName()) //for all duration.[label] properties .map(environment::getProperty).filter(Objects::nonNull) //look for a Duration .findFirst().map(Duration::parse).orElse(defaultReviewWindow); //if none found, use the default window ZonedDateTime creationTime = pullRequest.getCreatedAt(); ZonedDateTime windowCloseTime = creationTime.plus(reviewTime); boolean windowPassed = now().isAfter(windowCloseTime); logger.info("creationTime({}) + reviewTime({}) = windowCloseTime({}), so windowPassed = {}", creationTime, reviewTime, windowCloseTime, windowPassed); if (windowPassed) { completeAndCleanUp(asyncTasks, repository, head); } else { createPendingMessage(repository, head, reviewTime); ScheduledFuture<?> scheduledTask = taskScheduler.schedule( () -> completeAndCleanUp(asyncTasks, repository, head), Date.from(windowCloseTime.toInstant())); replaceCompletionTask(asyncTasks, scheduledTask, head); } } catch (IOException ex) { throw Throwables.propagate(ex); } }; }
From source file:com.ibm.watson.catalyst.jumpqa.template.ATemplate.java
private final List<Candidate> answers2candidates(Collection<Answer> answers) { final List<Candidate> result = new ArrayList<Candidate>(); answers.stream().forEachOrdered((answer) -> result.addAll(answer.splitInto(_candidateSize))); return result; }
From source file:com.ejisto.modules.dao.local.LocalMockedFieldsDao.java
@Override public void insert(final Collection<MockedField> mockedFields) { transactionalOperation(() -> {/*w w w.ja v a 2s. c om*/ mockedFields.stream().forEach(this::internalInsert); return null; }); }
From source file:com.bekioui.jaxrs.server.core.NettyServer.java
private void providers(ResteasyDeployment deployment) { Collection<Object> providers = applicationContext.getBeansWithAnnotation(Provider.class).values(); List<Object> toDelete = providers.stream() // .filter(p -> (!corsEnabled && p instanceof ResteasyCorsFilter) // || (!securityEnabled && p instanceof AuthorizationFilter)) // .collect(Collectors.toList()); providers.removeAll(toDelete);//from w ww .j a va 2 s .c om deployment.getProviders().addAll(providers); }
From source file:com.yahoo.elide.parsers.state.RelationshipTerminalState.java
private boolean post(Data<Resource> data, RequestScope requestScope) { if (data == null) { throw new InvalidEntityBodyException("Expected data but received null"); }//w w w.ja v a 2 s .c o m Collection<Resource> resources = data.get(); if (resources == null) { return false; } resources.stream().forEachOrdered( resource -> record.addRelation(relationshipName, resource.toPersistentResource(requestScope))); return true; }
From source file:ch.wisv.areafiftylan.products.service.OrderServiceImpl.java
@Override public List<Order> getOpenOrders(String username) { Collection<Order> ordersByUsername = findOrdersByUsername(username); return ordersByUsername.stream().filter(o -> o.getStatus().equals(OrderStatus.CREATING)) .collect(Collectors.toList()); }
From source file:org.obiba.mica.core.service.MailService.java
@Async public void sendEmailToGroupsAndUsers(String subject, String template, Map<String, String> context, Collection<String> groups, Collection<String> users) { String groupsParam = toRecipientFormParam("group", groups.stream().toArray(String[]::new)); String usernameParam = toRecipientFormParam("username", users.stream().toArray(String[]::new)); sendEmail(subject, template, context, Joiner.on("&").join( Stream.of(groupsParam, usernameParam).filter(s -> !Strings.isNullOrEmpty(s)).collect(toList()))); }
From source file:ch.icclab.cyclops.persistence.orm.InstanceORM.java
private String getListAsString(Collection col) { List<String> list = new ArrayList<>(); col.stream().forEach(elt -> list.add(elt.toString())); return String.join(",", list); }