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:com.vsct.dt.strowgr.admin.gui.mapping.json.UpdatedEntryPointBackendMappingJson.java

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

From source file:com.synopsys.integration.blackduck.service.model.ComponentVersionPolicyViolationCount.java

public ComponentVersionPolicyViolationCount(final NameValuePairView nameValuePair) {
    final Set<PolicySeverityType> policySeverityTypes = EnumSet.allOf(PolicySeverityType.class);
    final Set<String> policyStatusTypeValues = policySeverityTypes.stream().map(Object::toString)
            .collect(Collectors.toSet());
    if (policyStatusTypeValues.contains(nameValuePair.getName())) {
        name = PolicySeverityType.valueOf(nameValuePair.getName());
    }//from   w w w. j  a  v a  2  s .c  o m

    if (nameValuePair.getValue() != null) {
        final String valueString = nameValuePair.getValue().toString();
        if (NumberUtils.isCreatable(valueString)) {
            value = NumberUtils.createNumber(valueString).intValue();
        }
    }
}

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

@Override
public Set<Application> findAll() throws TechnicalException {
    Set<RedisApplication> applications = applicationRedisRepository.findAll();

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

From source file:com.synopsys.integration.blackduck.service.model.ComponentVersionStatusCount.java

public ComponentVersionStatusCount(final NameValuePairView nameValuePair) {
    final Set<PolicySummaryStatusType> policyStatusTypes = EnumSet.allOf(PolicySummaryStatusType.class);
    final Set<String> policyStatusTypeValues = policyStatusTypes.stream().map(Object::toString)
            .collect(Collectors.toSet());
    if (policyStatusTypeValues.contains(nameValuePair.getName())) {
        name = PolicySummaryStatusType.valueOf(nameValuePair.getName());
    }//from   ww  w . j a va  2  s.c  om

    if (nameValuePair.getValue() != null) {
        final String valueString = nameValuePair.getValue().toString();
        if (NumberUtils.isCreatable(valueString)) {
            value = NumberUtils.createNumber(valueString).intValue();
        }
    }
}

From source file:com.wmfsystem.eurekaserver.broadcast.Server.java

public void run() {
    try {/* w w  w .j  av a2s .  c  om*/
        socket = new DatagramSocket(DEFAULT_PORT);
    } catch (Exception ex) {
        System.out.println("Problem creating socket on port: " + DEFAULT_PORT);
    }

    packet = new DatagramPacket(new byte[1], 1);

    while (true) {
        try {
            socket.receive(packet);
            System.out.println("Received from: " + packet.getAddress() + ":" + packet.getPort());
            byte[] outBuffer = new java.util.Date().toString().getBytes();
            packet.setData(outBuffer);
            packet.setLength(outBuffer.length);
            socket.setBroadcast(true);
            socket.send(packet);

            Set<InetAddress> localAddress = getLocalAddress();

            Set<String> ips = localAddress.stream().map(ad -> ad.getHostAddress()).collect(Collectors.toSet())
                    .stream().sorted().collect(Collectors.toSet());

            RestTemplate template = new RestTemplate();

            ips.forEach(ip -> {
                template.exchange("http://" + packet.getAddress().getHostAddress().concat(":8000?ip={ip}"),
                        HttpMethod.GET, HttpEntity.EMPTY, Void.class, ip.concat(":8000"));
                try {
                    template.exchange("http://" + packet.getAddress().getHostAddress().concat(":8000?ip={ip}"),
                            HttpMethod.GET, HttpEntity.EMPTY, Void.class, ip.concat(":8000"));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });

            System.out.println("Message ----> " + packet.getAddress().getHostAddress());

        } catch (IOException ie) {
            ie.printStackTrace();
        }
    }
}

From source file:com.blackducksoftware.integration.hub.detect.workflow.detector.RequiredDetectorChecker.java

public RequiredDetectorResult checkForMissingDetectors(final String requiredDetectorsString,
        final Set<DetectorType> applicableDetectors) {
    final Set<DetectorType> required = parseRequiredDetectors(requiredDetectorsString);

    final Set<DetectorType> missingDetectors = required.stream().filter(it -> !applicableDetectors.contains(it))
            .collect(Collectors.toSet());

    return new RequiredDetectorResult(missingDetectors);
}

From source file:io.gravitee.management.service.impl.EventServiceImpl.java

private Set<EventEntity> convert(Set<Event> events) {
    return events.stream().map(this::convert).collect(Collectors.toSet());
}

From source file:nu.yona.server.batch.quartz.JobManagementService.java

@Transactional
public Set<JobDto> updateJobGroup(String group, Set<JobDto> jobs) {
    try {/*from w w w  .  ja v  a2 s  . com*/
        Set<String> jobNamesToBe = jobs.stream().map(JobDto::getName).collect(toSet());
        Set<JobKey> existingJobs = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(group));
        Set<JobKey> keysOfJobsToDelete = existingJobs.stream().filter(jk -> !contains(jobNamesToBe, jk))
                .collect(toSet());
        Set<JobDto> jobsToUpdate = jobs.stream().filter(j -> contains(existingJobs, group, j)).collect(toSet());
        Set<JobDto> jobsToAdd = jobs.stream().filter(j -> !contains(existingJobs, group, j)).collect(toSet());

        keysOfJobsToDelete.forEach(jk -> deleteJob(jk.getGroup(), jk.getName()));
        jobsToUpdate.forEach(j -> updateJob(group, j));
        jobsToAdd.forEach(j -> addJob(group, j));

        return getJobsInGroup(group);
    } catch (SchedulerException e) {
        throw YonaException.unexpected(e);
    }
}

From source file:io.knotx.knot.action.ActionKnotProxyImpl.java

@Override
protected boolean shouldProcess(Set<String> knots) {
    return knots.stream().anyMatch(knot -> knot.startsWith(FRAGMENT_KNOT_PREFIX));
}

From source file:act.installer.bing.BingSearcher.java

public void addBingSearchResultsForInchiSet(Set<String> inchis) {
    Set<String> filteredInchis = inchis.stream().filter(inchi -> !inchi.contains("FAKE"))
            .collect(Collectors.toSet());
    LOGGER.info("Annotating %d chemicals with Bing Search results and usage terms.", filteredInchis.size());
    int counter = 0;
    for (String inchi : filteredInchis) {
        if (!forceUpdate && db.hasBingSearchResultsFromInchi(inchi)) {
            LOGGER.debug("Existing Bing search results found for %s. Skipping.", inchi);
            continue;
        }/*  w w  w .ja  va2 s . c  o  m*/
        try {
            addBingSearchResultsForInChI(inchi);
        } catch (IOException e) {
            LOGGER.error("Could not add bing results for %s. Skipping.", inchi);
        }
        if (++counter % 100 == 0) {
            LOGGER.info("Added Bing Search results for %d chemicals (total %d)", counter,
                    filteredInchis.size());
        }
    }
}