Example usage for java.util.stream Collectors toSet

List of usage examples for java.util.stream Collectors toSet

Introduction

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

Prototype

public static <T> Collector<T, ?, Set<T>> toSet() 

Source Link

Document

Returns a Collector that accumulates the input elements into a new Set .

Usage

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

@Override
public Set<Tag> findAll() throws TechnicalException {
    final Set<RedisTag> tags = tagRedisRepository.findAll();

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

From source file:io.gravitee.repository.redis.management.internal.impl.ApiRedisRepositoryImpl.java

@Override
public Set<RedisApi> findAll() {
    Map<Object, Object> applications = redisTemplate.opsForHash().entries(REDIS_KEY);

    return applications.values().stream().map(object -> convert(object, RedisApi.class))
            .collect(Collectors.toSet());
}

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

@Override
public Set<Application> findByGroups(List<String> groupIds) throws TechnicalException {
    return applicationRedisRepository.findByGroups(groupIds).stream().map(this::convert)
            .collect(Collectors.toSet());
}

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

@GET
@Path("/all")
@Produces(MediaType.APPLICATION_JSON)//w w w  .jav  a  2  s.  c om
@ApiOperation(value = "all", response = ComputingDomain.class, responseContainer = "Set")
public Response getAllComputingDomains() {

    List<se.uu.it.cs.recsys.persistence.entity.ComputingDomain> all = this.computingDomainRepository.findAll();

    Set<ComputingDomain> output = all.stream()
            .map(entity -> new ComputingDomain(entity.getId(), entity.getName())).collect(Collectors.toSet());

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

}

From source file:ImportPhagelist.java

private void getStrains(String path1) throws IOException {
    String cvsSplitBy = "\\t";
    List<String[]> lines = null;
    try (FileInputStream fis = new FileInputStream(path1);
            BufferedReader br = new BufferedReader(new InputStreamReader(fis))) {
        lines = br.lines().map((l) -> l.split(cvsSplitBy)).collect(Collectors.toList());
    } catch (FileNotFoundException e) {
        e.printStackTrace();/* w w w .j a  v a  2  s.  c om*/
    }
    this.strains = lines.stream().skip(1).map(x -> x[1]).collect(Collectors.toSet());
    ;

}

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

@Override
public Set<View> findAll() throws TechnicalException {
    final Set<RedisView> views = viewRedisRepository.findAll();

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

From source file:io.gravitee.management.idp.repository.lookup.RepositoryIdentityLookup.java

@Override
public Collection<User> search(String query) {
    try {/* ww w  . j  av  a  2  s.co m*/
        return userRepository.findAll().stream().map(this::convert).collect(Collectors.toSet());
    } catch (TechnicalException te) {
        LOGGER.error("Unexpected error while searching for users in repository", te);
        return null;
    }
}

From source file:io.gravitee.repository.redis.management.internal.impl.PageRedisRepositoryImpl.java

@Override
public Set<RedisPage> findByApi(String api) {
    Set<Object> keys = redisTemplate.opsForSet().members(REDIS_KEY + ":api:" + api);
    List<Object> pageObjects = redisTemplate.opsForHash().multiGet(REDIS_KEY, keys);

    return pageObjects.stream().map(event -> convert(event, RedisPage.class)).collect(Collectors.toSet());
}

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

@Override
public Set<User> findByUsernames(List<String> usernames) throws TechnicalException {
    return userRedisRepository.find(usernames).stream().map(this::convert).collect(Collectors.toSet());
}

From source file:com.epam.ta.reportportal.core.acl.chain.DashboardChainElement.java

@Override
public List<? extends Shareable> getNextElements(List<? extends Shareable> elementsToProcess, String owner) {
    Set<String> ids = elementsToProcess.stream().map(e -> (Dashboard) e).flatMap(d -> d.getWidgets().stream())
            .map(Dashboard.WidgetObject::getWidgetId).collect(Collectors.toSet());
    return Lists.newArrayList(widgetRepository.findOnlyOwnedEntities(ids, owner));
}