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.klerch.alexa.tellask.model.wrapper.AlexaRequestStreamHandler.java

/**
 * Provides a set of application-id(s) you can find in the Alexa developer console of your skill.
 * Only requests coming in with these application-id(s) pass the request verification.
 * @return supported application ids//from  w  w  w  .j  av  a  2 s . co  m
 */
public Set<String> getSupportedApplicationIds() {
    final AlexaApplication app = this.getClass().getAnnotation(AlexaApplication.class);
    return app != null ? Stream.of(app.applicationIds()).collect(Collectors.toSet()) : Collections.emptySet();
}

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

@Override
public Set<ApiKey> findBySubscription(String subscription) throws TechnicalException {
    return apiKeyRedisRepository.findBySubscription(subscription).stream().map(this::convert)
            .collect(Collectors.toSet());
}

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

@Override
public Set<Api> findByIds(List<String> ids) throws TechnicalException {
    return apiRedisRepository.find(ids).stream().map(this::convert).collect(Collectors.toSet());
}

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

@Before
public void init() throws Exception {
    JedisCommands jedisMock = new JedisMock();
    dao = new DynoQueueDAO(jedisMock, jedisMock, new ShardSupplier() {

        @Override//  w w w . j  a v a  2  s.  co  m
        public Set<String> getQueueShards() {
            return Arrays.asList("a").stream().collect(Collectors.toSet());
        }

        @Override
        public String getCurrentShard() {
            return "a";
        }
    }, new TestConfiguration());
}

From source file:com.hp.autonomy.frontend.configuration.authentication.IdolPreAuthenticatedAuthenticationProvider.java

@Override
public Authentication authenticate(final Authentication authentication) throws AuthenticationException {
    final Object principal = authentication.getPrincipal();

    if (principal == null) {
        throw new BadCredentialsException("Principal not supplied");
    }//from ww  w. j  a v  a2 s.  com

    final String username = principal.toString().toLowerCase();

    final UserRoles user = userService.getUser(username, true);

    final Collection<SimpleGrantedAuthority> grantedAuthorities = preAuthenticatedRoles.stream()
            .map(SimpleGrantedAuthority::new).collect(Collectors.toSet());

    final CommunityPrincipal communityPrincipal = new CommunityPrincipal(user.getUid(), username,
            user.getSecurityInfo(), Collections.emptySet());
    final Collection<? extends GrantedAuthority> authorities = authoritiesMapper
            .mapAuthorities(grantedAuthorities);
    return new UsernamePasswordAuthenticationToken(communityPrincipal, null, authorities);
}

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

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

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

From source file:com.netflix.spinnaker.fiat.providers.BaseProvider.java

@Override
@SuppressWarnings("unchecked")
public Set<R> getAllUnrestricted() throws ProviderException {
    return (Set<R>) getAll().stream().filter(resource -> resource instanceof Resource.AccessControlled)
            .map(resource -> (Resource.AccessControlled) resource)
            .filter(resource -> !resource.getPermissions().isRestricted()).collect(Collectors.toSet());
}

From source file:edu.washington.gs.skyline.model.quantification.QuantificationTest.java

public void testNoNormalization() throws Exception {
    List<InputRecord> allInputRecords = readInputRecords("NoNormalizationInput.csv");
    allInputRecords = filterRecords(NormalizationMethod.NONE, allInputRecords);
    Map<RecordKey, Double> expected = readExpectedRows("NoNormalizationExpected.csv");
    for (Map.Entry<RecordKey, Double> entry : expected.entrySet()) {
        List<InputRecord> peptideRecords = allInputRecords.stream()
                .filter(record -> record.getRecordKey().getPeptideKey().equals(entry.getKey().getPeptideKey()))
                .collect(Collectors.toList());
        TransitionKeys allTransitionKeys = TransitionKeys
                .of(peptideRecords.stream().map(InputRecord::getTransitionKey).collect(Collectors.toSet()));
        List<InputRecord> replicateRecords = allInputRecords.stream()
                .filter(record -> record.getRecordKey().equals(entry.getKey())).collect(Collectors.toList());
        Map<String, Double> areaMap = replicateRecords.stream()
                .collect(Collectors.toMap(InputRecord::getTransitionKey, InputRecord::getArea));
        TransitionAreas transitionAreas = TransitionAreas.fromMap(areaMap);
        assertCloseEnough(entry.getValue(), transitionAreas.totalArea(allTransitionKeys));
    }/*from www  .j  a va2  s .co m*/
}

From source file:io.interface21.domain.DataLoader.java

private Set<Question> buildSysQuestions() {
    return Stream.of(new Question[] { new MultipleChoiceQuestion("What is a discrete transformation algorithm?",
            1, BigDecimal.valueOf(0L),
            Stream.of(new CheckableAnswerDefinition[] {
                    new CheckableAnswerDefinition("Laplace", 1, BigDecimal.valueOf(0L)),
                    new CheckableAnswerDefinition("Fourier", 2, BigDecimal.valueOf(0L)),
                    new CheckableAnswerDefinition("Z", 3, BigDecimal.valueOf(100L)),
                    new CheckableAnswerDefinition("Garett", 4, BigDecimal.valueOf(0L)) })
                    .collect(Collectors.toSet())) })
            .collect(Collectors.toSet());
}

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

@Override
public Set<RedisGroup> findByType(String type) {
    Set<Object> keys = redisTemplate.opsForSet().members(REDIS_KEY + ":type:" + type);
    List<Object> groupObjects = redisTemplate.opsForHash().multiGet(REDIS_KEY, keys);

    return groupObjects.stream().map(grp -> convert(grp, RedisGroup.class)).collect(Collectors.toSet());
}