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.batch.quartz.TriggerManagementService.java

@Transactional
public Set<CronTriggerDto> updateTriggerGroup(String group, Set<CronTriggerDto> triggers) {
    try {//from   w ww  .j  av a  2s.  co  m
        Set<String> trgNamesToBe = triggers.stream().map(CronTriggerDto::getName).collect(toSet());
        Set<TriggerKey> existingTrgs = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(group));
        Set<TriggerKey> keysOfTrgsToDelete = existingTrgs.stream().filter(tk -> !contains(trgNamesToBe, tk))
                .collect(toSet());
        Set<CronTriggerDto> trgsToUpdate = triggers.stream().filter(t -> contains(existingTrgs, group, t))
                .collect(toSet());
        Set<CronTriggerDto> trgsToAdd = triggers.stream().filter(t -> !contains(existingTrgs, group, t))
                .collect(toSet());

        keysOfTrgsToDelete.forEach(tk -> deleteTrigger(tk.getGroup(), tk.getName()));
        trgsToUpdate.forEach(t -> updateTrigger(group, t));
        trgsToAdd.forEach(t -> addTrigger(group, t));

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

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

@JsonCreator
public UpdatedEntryPointMappingJson(@JsonProperty("hapUser") String hapUser,
        @JsonProperty("hapVersion") String hapVersion, @JsonProperty("bindingId") int bindingId,
        @JsonProperty("context") Map<String, String> context,
        @JsonProperty("frontends") Set<UpdatedEntryPointFrontendMappingJson> frontends,
        @JsonProperty("backends") Set<UpdatedEntryPointBackendMappingJson> backends) {
    super(bindingId, hapUser, context, frontends.stream().map(identity()).collect(Collectors.toSet()),
            backends.stream().map(identity()).collect(Collectors.toSet()), hapVersion);
}

From source file:me.adaptive.core.data.api.WorkspaceMemberService.java

public List<Member> toMemberList(Set<WorkspaceMemberEntity> workspaceMemberEntities) {
    List<Member> members = new ArrayList<>(workspaceMemberEntities.size());
    members.addAll(workspaceMemberEntities.stream().map(this::toMember).collect(Collectors.toList()));
    return members;
}

From source file:com.thinkbiganalytics.feedmgr.nifi.CleanupStaleFeedRevisions.java

private void stopPorts(Set<PortDTO> ports) {
    if (!ports.isEmpty()) {
        ports.stream().filter(portDTO -> !stoppedPorts.contains(portDTO)).forEach(portDTO1 -> {
            if (isInputPort(portDTO1)) {
                restClient.stopInputPort(portDTO1.getParentGroupId(), portDTO1.getId());
                stoppedPorts.add(portDTO1);
            } else {
                restClient.stopOutputPort(portDTO1.getParentGroupId(), portDTO1.getId());
                stoppedPorts.add(portDTO1);
            }//from  w  w  w .  j  a  va2s.  c o m
        });
    }
}

From source file:com.github.mrstampy.gameboot.otp.OneTimePadTest.java

private void metrics() throws Exception {
    Set<Entry<String, Timer>> timers = helper.getTimers();

    timers.stream().filter(e -> isMetric(e.getKey())).forEach(e -> display(e));
}

From source file:ch.ifocusit.livingdoc.plugin.diagram.PlantumlClassDiagramBuilder.java

public String generate() throws MojoExecutionException {
    final ClassPath classPath = initClassPath();
    final Set<ClassInfo> allClasses = classPath.getTopLevelClassesRecursive(prefix);

    String diagram = classDiagramBuilder.addClasse(allClasses.stream()
            // apply filters
            .filter(defaultFilter()).filter(additionalClassPredicate).map(classInfo -> {
                try {
                    return classInfo.load();
                } catch (Throwable e) {
                    LOG.warn(e.toString());
                }/*from   w  w  w  . ja v  a 2 s . c om*/
                return null;
            }).filter(Objects::nonNull).collect(Collectors.toList())).excludes(excludes).setHeader(readHeader())
            .setFooter(readFooter()).withNamesMapper(namesMapper).withLinkMaker(this)
            .withDependencies(diagramWithDependencies).build();
    return diagram;
}

From source file:de.blizzy.rust.lootconfig.LootConfigDump.java

private void fillItemCategoryDropChances(Category itemCategory, Set<SubSpawn> subSpawns, float parentChance,
        Multiset<Float> itemCategoryDropChances) {
    int totalWeight = subSpawns.stream().collect(Collectors.summingInt(subSpawn -> subSpawn.Weight));

    for (SubSpawn subSpawn : subSpawns) {
        float subSpawnChance = parentChance * subSpawn.Weight / totalWeight;
        if (subSpawn.Category == itemCategory) {
            itemCategoryDropChances.add(subSpawnChance);
        } else if (subSpawn.Category.hasSubSpawns()) {
            fillItemCategoryDropChances(itemCategory, subSpawn.Category.SubSpawn, subSpawnChance,
                    itemCategoryDropChances);
        }/*from  w  w w .jav a2  s .  co m*/
    }
}

From source file:se.uu.it.cs.recsys.service.resource.FrequenPatternResource.java

@GET
@Path("/find")
@Produces(MediaType.APPLICATION_JSON)/*from   ww  w  .j av  a  2  s  .c om*/
@ApiOperation(value = "find", notes = "list all frequent patterns", responseContainer = "Map")
public Response listAllFrequentPatterns(@QueryParam("codes") Set<String> codes,
        @QueryParam("minSupport") Integer minSupport) {

    if (codes == null || codes.isEmpty()) {
        return Response.ok().build();
    }

    Set<Integer> courseIds = new HashSet<>();

    codes.forEach(code -> {
        Set<se.uu.it.cs.recsys.persistence.entity.Course> courses = this.courseRepository.findByCode(code);
        Set<Integer> ids = courses.stream().map(entry -> entry.getAutoGenId()).collect(Collectors.toSet());

        courseIds.addAll(ids);
    });

    Map<Set<Integer>, Integer> patterns = this.ruleMiner.getPatterns(courseIds, minSupport);

    Map<Set<Course>, Integer> output = convertToCourse(patterns);

    return Response.ok(output, MediaType.APPLICATION_JSON).build();

}

From source file:ru.anr.base.services.BaseServiceImpl.java

/**
 * Extract all error message from {@link ConstraintViolation} as a single
 * string//www  . j  a va2s . c  om
 * 
 * @param violations
 *            collection of violations
 * @return All errors as a comma-separated string
 */
protected String getAllErrorsAsString(Set<ConstraintViolation<?>> violations) {

    return violations.stream().map(v -> v.getMessage()).collect(Collectors.toList()).toString();
}

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

private void sendResponseTime(Set<String> keys, long requestTime, boolean targetIsUndef) {
    long realRequestTime = targetIsUndef ? 0 : requestTime;
    keys.stream().forEach(key -> statsdClient.timing(key + ".requestTime", realRequestTime));
}