List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:com.yfiton.core.Yfiton.java
private Map<String, Map<String, String>> loadPreferences(HierarchicalINIConfiguration configuration, Notifier notifier) {/*from w w w. j a v a2 s . c om*/ Set<String> sections = configuration.getSections(); return sections.stream().filter(isEqual(null).negate().and(section -> notifier.getKey().equals(section))) .collect(Collectors.toMap(Function.identity(), section -> configuration.getSection(section).getRootNode().getChildren().stream().collect( Collectors.toMap(ConfigurationNode::getName, node -> (String) node.getValue())))); }
From source file:io.gravitee.repository.redis.management.RedisMembershipRepository.java
@Override public Set<Membership> findByReferencesAndMembershipType(MembershipReferenceType referenceType, List<String> referenceIds, String membershipType) throws TechnicalException { Set<RedisMembership> memberships = membershipRedisRepository.findByReferences(referenceType.name(), referenceIds);//from w w w.j a va 2s.c o m if (membershipType == null) { return memberships.stream().map(this::convert).collect(Collectors.toSet()); } else { return memberships.stream().filter(membership -> membershipType.equals(membership.getType())) .map(this::convert).collect(Collectors.toSet()); } }
From source file:se.uu.it.cs.recsys.semantic.ComputingDomainReasoner.java
/** * The method first get narrower domains ids and then get related course ids * to these domain ids/*from ww w . ja va2 s. c om*/ * * @param domainIds * @return */ public Set<String> getNarrowerCourseIdsForCollection(Set<String> domainIds) { Set<String> r = new HashSet<>(); domainIds.stream().forEach((id) -> { try { r.addAll(getNarrowerDomainIds(id)); } catch (IOException ex) { LOGGER.error("Failed querying narrower ids for {}", id, ex); } }); return r; }
From source file:se.uu.it.cs.recsys.semantic.ComputingDomainReasoner.java
/** * @param domainIds/*w w w . j a v a 2 s.c o m*/ * @return join set of related course ids to each domain id, indirectly and * directly * @see DomainReasoner#getRelatedCourseIds(String) */ public Set<String> getRelatedCourseIdsForCollection(Set<String> domainIds) { Set<String> r = new HashSet<>(); domainIds.stream().forEach((id) -> { try { r.addAll(getRelatedDomainIds(id)); } catch (IOException ex) { LOGGER.error("Failed querying narrower ids for {}", id, ex); } }); return r; }
From source file:io.gravitee.repository.redis.management.RedisMembershipRepository.java
@Override public Set<Membership> findByUserAndReferenceTypeAndMembershipType(String userId, MembershipReferenceType referenceType, String membershipType) throws TechnicalException { Set<RedisMembership> memberships = membershipRedisRepository.findByUserAndReferenceType(userId, referenceType.name());/*www .ja v a 2 s . co m*/ if (membershipType == null) { return memberships.stream().map(this::convert).collect(Collectors.toSet()); } else { return memberships.stream().filter(membership -> membershipType.equals(membership.getType())) .map(this::convert).collect(Collectors.toSet()); } }
From source file:ddf.catalog.metacard.duplication.DuplicationValidator.java
private Filter[] buildFilters(Set<Attribute> attributes) { Filter[] filters = attributes.stream().flatMap(attribute -> { return attribute.getValues().stream().map( value -> filterBuilder.attribute(attribute.getName()).equalTo().text(value.toString().trim())); }).toArray(Filter[]::new); return filters; }
From source file:io.syndesis.rest.v1.handler.connection.ConnectionHandler.java
@Override public Connection create(@Context SecurityContext sec, @ConvertGroup(from = Default.class, to = AllValidations.class) final Connection connection) { final Date rightNow = new Date(); final Connection updatedConnection = new Connection.Builder().createFrom(connection).createdDate(rightNow) .lastUpdated(rightNow).userId(sec.getUserPrincipal().getName()).build(); final Set<CredentialFlowState> flowStates = CredentialFlowState.Builder.restoreFrom(state::restoreFrom, request);/*from www.ja va 2 s .c o m*/ final Connection connectionToCreate = flowStates.stream().map(s -> { final Cookie removal = new Cookie(s.persistenceKey(), ""); removal.setPath("/"); removal.setMaxAge(0); response.addCookie(removal); return credentials.apply(updatedConnection, s); }).findFirst().orElse(updatedConnection); return Creator.super.create(sec, connectionToCreate); }
From source file:nu.yona.server.goals.service.ActivityCategoryService.java
private void deleteRemovedActivityCategories(Set<ActivityCategory> activityCategoriesInRepository, Set<ActivityCategoryDto> activityCategoryDtos) { Map<UUID, ActivityCategoryDto> activityCategoryDtosMap = activityCategoryDtos.stream() .collect(Collectors.toMap(ActivityCategoryDto::getId, ac -> ac)); activityCategoriesInRepository.stream().filter(ac -> !activityCategoryDtosMap.containsKey(ac.getId())) .forEach(this::deleteActivityCategory); }
From source file:com.collective.celos.servlet.RegisterKeysServlet.java
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException { try {//from w ww. ja va 2 s . c o m BucketID bucket = new BucketID(req.getParameter(CelosClient.BUCKET_PARAM)); String prefix = req.getParameter(CelosClient.PREFIX_PARAM); try (StateDatabaseConnection connection = getStateDatabase().openConnection()) { Set<RegisterKey> keys = connection.getRegisterKeys(bucket, prefix); ObjectNode object = Util.MAPPER.createObjectNode(); ArrayNode list = Util.MAPPER.createArrayNode(); object.put(CelosClient.KEYS_NODE, list); keys.stream().sorted().forEach(x -> list.add(x.toString())); writer.writeValue(res.getOutputStream(), object); } } catch (Exception e) { throw new ServletException(e); } }
From source file:ai.grakn.engine.tasks.manager.multiqueue.Scheduler.java
/** * Get all recurring tasks from the graph and schedule them *//* ww w . j a va 2s .c o m*/ private void restartRecurringTasks() { LOG.debug("Restarting recurring tasks"); Set<TaskState> tasks = storage.getTasks(null, null, null, null, 0, 0); tasks.stream().filter(state -> state.schedule().isRecurring()).filter(p -> p.status() != STOPPED) .forEach(this::scheduleTask); }