Example usage for java.util Set stream

List of usage examples for java.util Set stream

Introduction

In this page you can find the example usage for java.util Set stream.

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:account.dao.ContactDao.java

private Set<Place> createPlaces(Set<PlaceDTO> placesDTO) {
    Set<Place> places = new HashSet<>();

    placesDTO.stream().map((placeDTO) -> {
        Place place = new Place();
        place.setTitle(placeDTO.getTitle());
        place.setDescription(placeDTO.getDescription());
        place.setLatitude(placeDTO.getLatitude());
        place.setLongitude(placeDTO.getLongitude());
        return place;
    }).forEach((place) -> {/*from  ww w  . ja v a 2 s. c o  m*/
        places.add(place);
    });

    return places;
}

From source file:se.uu.it.cs.recsys.constraint.builder.ScheduleDomainBuilder.java

private Map<CourseSchedule, Set<Integer>> getTaughtYearAndStartPeriodToIdMapping(Set<CourseSchedule> schedule) {

    Map<CourseSchedule, Set<Integer>> taughtYearAndStartPeriodToIdMapping = new HashMap<>();

    schedule.forEach(sch -> {/*w  w  w  . j a  v a  2s.c o m*/
        Set<Course> courseSet = this.courseRepository.findByTaughtYearAndStartPeriod(sch.getTaughtYear(),
                sch.getStartPeriod());

        Set<Integer> idSet = courseSet.stream().map(c -> c.getAutoGenId()).collect(Collectors.toSet());

        taughtYearAndStartPeriodToIdMapping.put(sch, idSet);
    });

    return taughtYearAndStartPeriodToIdMapping;
}

From source file:io.galeb.router.handlers.completionListeners.StatsdCompletionListener.java

private void sendActiveConnCount(Set<String> keys, Integer clientOpenConnection, boolean targetIsUndef) {
    int conn = (clientOpenConnection != null && !targetIsUndef) ? clientOpenConnection : 0;
    keys.stream().forEach(key -> statsdClient.gauge(key + ".activeConns", conn));
}

From source file:alfio.manager.SpecialPriceManager.java

public boolean sendCodeToAssignee(List<SendCodeModification> input, String eventName, int categoryId,
        String username) {/*from  w  ww .  j a va2  s.  c  om*/
    final Event event = eventManager.getSingleEvent(eventName, username);
    final Organization organization = eventManager.loadOrganizer(event, username);
    Set<SendCodeModification> set = new LinkedHashSet<>(input);
    checkCodeAssignment(set, categoryId, event, username);
    Validate.isTrue(set.stream().allMatch(IS_CODE_PRESENT),
            "There are missing codes. Please check input file.");
    List<ContentLanguage> eventLanguages = i18nManager.getEventLanguages(event.getLocales());
    Validate.isTrue(!eventLanguages.isEmpty(),
            "No locales have been defined for the event. Please check the configuration");
    ContentLanguage defaultLocale = eventLanguages.contains(ContentLanguage.ENGLISH) ? ContentLanguage.ENGLISH
            : eventLanguages.get(0);
    set.forEach(m -> {
        Locale locale = Locale.forLanguageTag(StringUtils.defaultString(StringUtils.trimToNull(m.getLanguage()),
                defaultLocale.getLanguage()));
        Map<String, Object> model = TemplateResource.prepareModelForSendReservedCode(organization, event, m,
                eventManager.getEventUrl(event));
        notificationManager.sendSimpleEmail(event, m.getEmail(),
                messageSource.getMessage("email-code.subject", new Object[] { event.getDisplayName() }, locale),
                () -> templateManager.renderTemplate(event, TemplateResource.SEND_RESERVED_CODE, model,
                        locale));
        int marked = specialPriceRepository.markAsSent(ZonedDateTime.now(event.getZoneId()),
                m.getAssignee().trim(), m.getEmail().trim(), m.getCode().trim());
        Validate.isTrue(marked == 1, "Expected exactly one row updated, got " + marked);
    });
    return true;
}

From source file:com.netflix.conductor.dao.dynomite.RedisMetadataDAO.java

@Override
public List<String> findAll() {
    Set<String> wfNames = dynoClient.smembers(nsKey(WORKFLOW_DEF_NAMES));
    return wfNames.stream().collect(Collectors.toList());
}

From source file:com.liferay.apio.architect.impl.jaxrs.json.reader.MultipartBodyMessageBodyReader.java

private <T> Map<String, List<T>> _flattenMap(Map<String, Map<Integer, T>> indexedValueLists) {

    Set<Entry<String, Map<Integer, T>>> entries = indexedValueLists.entrySet();

    Stream<Entry<String, Map<Integer, T>>> stream = entries.stream();

    return stream.sorted(comparingByKey()).collect(Collectors.toMap(Entry::getKey, v -> {
        Map<Integer, T> map = v.getValue();

        return new ArrayList<>(map.values());
    }));//from  ww w  . ja  v  a 2 s . c  o  m
}

From source file:org.jodconverter.spring.JodConverterBean.java

/** Prints the available formats provided by the JODConverter module. */
private void logSupportedGroupFormats(final String text, final Set<DocumentFormat> formats) {

    LOGGER.info(text);/*from w  w w . j av  a 2s.  c om*/
    formats.stream().map(DocumentFormat::getName).forEach(LOGGER::info);
}

From source file:natalia.dymnikova.cluster.scheduler.impl.requirements.ComputeMemberRequirementsBuilder.java

private Entry<Field, Set<ScannedGenericBeanDefinition>> scan(TypeFilterWithField filter) {
    final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
            false, scannerEnvironment);/*from w ww. j a va 2  s  .  c o m*/

    scanner.setResourceLoader(resourcePatternResolver);
    scanner.setMetadataReaderFactory(metadataReaderFactory);

    scanner.resetFilters(false);
    scanner.addIncludeFilter(new CompositeFilter(new AnnotationTypeFilter(Component.class), filter));

    final Set<BeanDefinition> candidateComponents = scanner.findCandidateComponents(basePackage);

    final Set<ScannedGenericBeanDefinition> collect = candidateComponents.stream()
            .map(bd -> (ScannedGenericBeanDefinition) bd).collect(toSet());

    return new SimpleEntry<>(filter.field, collect);
}

From source file:com.oneops.transistor.util.CloudUtil.java

private Map<String, TreeSet<String>> getMissingCloudServices(String cloud, Set<String> cloudServices,
        Set<String> requiredServices) {
    Map<String, TreeSet<String>> missingCloud2Services = new TreeMap<>();
    requiredServices.stream().filter(s -> !cloudServices.contains(s))
            .forEach(s -> missingCloud2Services.computeIfAbsent(cloud, k -> new TreeSet<>()).add(s));
    logger.debug("cloud: " + cloud + " required services:: " + requiredServices.toString() + " missingServices "
            + missingCloud2Services.keySet());

    return missingCloud2Services;
}

From source file:de.ks.flatadocdb.defaults.ReflectionLuceneDocumentExtractor.java

@Override
public Document createDocument(Object instance) {
    Class<?> clazz = instance.getClass();
    Set<DocField> fields = getFields(clazz);

    Document doc = new Document();
    fields.stream().map(f -> f.apply(instance)).filter(Objects::nonNull).forEach(doc::add);
    return doc;//from   www  .ja v a  2 s . c o  m
}