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:nu.yona.server.analysis.service.InactivityManagementService.java

private void createWeekInactivityEntities(UUID userAnonymizedId, Set<IntervalInactivityDto> weekInactivities) {
    weekInactivities.stream().forEach(wi -> createWeekInactivity(userAnonymizedId, wi));
}

From source file:nu.yona.server.analysis.service.InactivityManagementService.java

private void createDayInactivityEntities(UserAnonymizedDto userAnonymized,
        Set<IntervalInactivityDto> dayInactivities) {
    dayInactivities.stream()
            .forEach(di -> createDayInactivity(userAnonymized.getId(),
                    createWeekInactivity(userAnonymized.getId(),
                            getGoal(userAnonymized, di.getGoalId()).getGoalId(),
                            TimeUtil.getStartOfWeek(userAnonymized.getTimeZone(), di.getStartTime())),
                    di));/*from   w  w w. jav  a 2  s  .c o  m*/
}

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

private void sendHttpMethodCount(Set<String> keys, String method) {
    keys.stream().forEach(key -> statsdClient.count(key + ".httpMethod." + method, 1));
}

From source file:com.netflix.genie.core.jpa.specifications.JpaJobSpecs.java

/**
 * Generate a criteria query predicate for a where clause based on the given parameters.
 *
 * @param root        The root to use/*w  w  w  . j  ava2  s.c  o  m*/
 * @param cb          The criteria builder to use
 * @param id          The job id
 * @param name        The job name
 * @param user        The user who created the job
 * @param statuses    The job statuses
 * @param tags        The tags for the jobs to find
 * @param clusterName The cluster name
 * @param cluster     The cluster the job should have been run on
 * @param commandName The command name
 * @param command     The command the job should have been run with
 * @param minStarted  The time which the job had to start after in order to be return (inclusive)
 * @param maxStarted  The time which the job had to start before in order to be returned (exclusive)
 * @param minFinished The time which the job had to finish after in order to be return (inclusive)
 * @param maxFinished The time which the job had to finish before in order to be returned (exclusive)
 * @return The specification
 */
public static Predicate getFindPredicate(final Root<JobEntity> root, final CriteriaBuilder cb, final String id,
        final String name, final String user, final Set<JobStatus> statuses, final Set<String> tags,
        final String clusterName, final ClusterEntity cluster, final String commandName,
        final CommandEntity command, final Date minStarted, final Date maxStarted, final Date minFinished,
        final Date maxFinished) {
    final List<Predicate> predicates = new ArrayList<>();
    if (StringUtils.isNotBlank(id)) {
        predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(JobEntity_.id), id));
    }
    if (StringUtils.isNotBlank(name)) {
        predicates
                .add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(JobEntity_.name), name));
    }
    if (StringUtils.isNotBlank(user)) {
        predicates
                .add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(JobEntity_.user), user));
    }
    if (statuses != null && !statuses.isEmpty()) {
        final List<Predicate> orPredicates = statuses.stream()
                .map(status -> cb.equal(root.get(JobEntity_.status), status)).collect(Collectors.toList());
        predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()])));
    }
    if (tags != null && !tags.isEmpty()) {
        predicates.add(cb.like(root.get(JobEntity_.tags), JpaSpecificationUtils.getTagLikeString(tags)));
    }
    if (cluster != null) {
        predicates.add(cb.equal(root.get(JobEntity_.cluster), cluster));
    }
    if (StringUtils.isNotBlank(clusterName)) {
        predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(JobEntity_.clusterName),
                clusterName));
    }
    if (command != null) {
        predicates.add(cb.equal(root.get(JobEntity_.command), command));
    }
    if (StringUtils.isNotBlank(commandName)) {
        predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(JobEntity_.commandName),
                commandName));
    }
    if (minStarted != null) {
        predicates.add(cb.greaterThanOrEqualTo(root.get(JobEntity_.started), minStarted));
    }
    if (maxStarted != null) {
        predicates.add(cb.lessThan(root.get(JobEntity_.started), maxStarted));
    }
    if (minFinished != null) {
        predicates.add(cb.greaterThanOrEqualTo(root.get(JobEntity_.finished), minFinished));
    }
    if (maxFinished != null) {
        predicates.add(cb.lessThan(root.get(JobEntity_.finished), maxFinished));
    }
    return cb.and(predicates.toArray(new Predicate[predicates.size()]));
}

From source file:io.gravitee.repository.redis.management.RedisUserRepository.java

@Override
public Set<User> findAll() throws TechnicalException {
    Set<RedisUser> users = userRedisRepository.findAll();

    return users.stream().map(this::convert).collect(Collectors.toSet());
}

From source file:imbrobits.loosh.core.BootstrapBinder.java

@Override
protected void configure() {
    bind(EntryPoint.class);
    // scan packages for handler
    Reflections reflections = new Reflections("imbrobits.loosh");
    Set<Class<?>> handlers = reflections.getTypesAnnotatedWith(Controller.class);
    handlers.stream().forEach(cls -> bind(cls));

    reflections = new Reflections("imbrobits.loosh.handler");
    Set<Class<? extends OAuth2Handler>> oauthHandlers = reflections.getSubTypesOf(OAuth2Handler.class);
    oauthHandlers.stream().forEach(cls -> bind(cls));

    // bind config to object for future usage
    bind(ProjectDao.class).to(ProjectDaoImpl.class);
}

From source file:com.vsct.dt.strowgr.admin.gui.mapping.json.EntryPointBackendMappingJson.java

public EntryPointBackendMappingJson(@JsonProperty("id") String id,
        @JsonProperty("servers") Set<EntryPointBackendServerMappingJson> servers,
        @JsonProperty("context") Map<String, String> context) {
    super(id, servers.stream().map(Function.identity()).collect(Collectors.toSet()), context);
}

From source file:io.curly.tagger.listener.EventHandler.java

@Selector("tag.bus")
public void handle(Set<TagMessage> message) {
    log.info("Initiating processor for tag message" + message + " received on Event Bus");
    writerCommand.save(message.stream().map(TagMessage::toTag).collect(Collectors.toSet()));
}

From source file:be.ordina.msdashboard.aggregators.index.IndexToNodeConverter.java

@SuppressWarnings("unchecked")
private List<Node> getNodesFromJSON(String serviceId, String serviceUri, JSONObject index) {
    List<Node> nodes = new ArrayList<>();

    NodeBuilder serviceNode = NodeBuilder.node().withId(serviceId).withLane(2);

    JSONObject links = index.getJSONObject(LINKS);
    final boolean hasCuries = links.has(CURIES);

    Set<String> keyset = new HashSet<>(links.keySet());

    keyset.stream().filter(linkKey -> !CURIES.equals(linkKey)).forEach(linkKey -> {
        serviceNode.withLinkedFromNodeId(linkKey);

        JSONObject link = links.getJSONObject(linkKey);

        Node linkedNode = convertLinkToNodes(linkKey, link, serviceId);
        if (hasCuries) {
            String docs = resolveDocs(linkKey, links.getJSONArray(CURIES), serviceUri);

            if (docs != null) {
                linkedNode.addDetail("docs", docs);
            }//from w w w .j a  v a  2 s  . c om
        }

        nodes.add(linkedNode);
    });

    nodes.add(0, serviceNode.build());

    return nodes;
}

From source file:io.gravitee.repository.redis.management.RedisApiRepository.java

@Override
public Set<Api> findAll() throws TechnicalException {
    Set<RedisApi> apis = apiRedisRepository.findAll();

    return apis.stream().map(this::convert).collect(Collectors.toSet());
}