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:com.netflix.spinnaker.clouddriver.aws.provider.view.AmazonS3DataProvider.java

@Autowired
public AmazonS3DataProvider(ObjectMapper objectMapper, AmazonClientProvider amazonClientProvider,
        AccountCredentialsRepository accountCredentialsRepository,
        AmazonS3StaticDataProviderConfiguration configuration) {
    this.objectMapper = objectMapper;
    this.amazonClientProvider = amazonClientProvider;
    this.accountCredentialsRepository = accountCredentialsRepository;
    this.configuration = configuration;

    this.supportedIdentifiers = configuration.getStaticRecords().stream().map(r -> r.getId().toLowerCase())
            .collect(Collectors.toSet());
}

From source file:io.knotx.knot.AbstractKnotProxy.java

private Set<String> getKnotSet(List<Fragment> fragments) {
    return fragments.stream().map(Fragment::knots).flatMap(Collection::stream).collect(Collectors.toSet());
}

From source file:org.artifactory.ui.rest.service.artifacts.browse.treebrowser.tabs.general.licenses.GetArchiveLicenseFileService.java

private Set<String> getPossibleLicenseFileNames() {
    return Stream.of(StringUtils.split(ConstantValues.archiveLicenseFileNames.getString(), ","))
            .map(StringUtils::trim).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
}

From source file:org.fenixedu.spaces.ui.SpaceSearchController.java

private Set<Space> findSpace(String text) {
    return Space.getSpaces().filter(s -> {
        List<String> toksToFind = Arrays.asList(text.toLowerCase().split(" "));
        List<String> toks = Arrays.asList(s.getFullName().toLowerCase().split(" "));
        for (String token : toksToFind) {
            boolean contains = false;
            for (String ss : toks) {
                if (ss.contains(token)) {
                    contains = true;// www.j  a va2 s.  com
                    break;
                }
            }
            if (contains == false) {
                return false;
            }
        }
        return true;
    }).sorted().collect(Collectors.toSet());
}

From source file:ch.algotrader.service.fix.FixOrderServiceImpl.java

protected Set<String> getAllSessionQualifiers() {

    List<Account> accounts = getAllAccounts();
    return accounts.stream().filter(account -> !StringUtils.isEmpty(account.getSessionQualifier()))
            .map(Account::getSessionQualifier).collect(Collectors.toSet());
}

From source file:com.netflix.genie.web.data.services.jpa.JpaServiceUtils.java

/**
 * Convert a cluster entity to a DTO for external exposure.
 *
 * @param clusterEntity The entity to convert
 * @return The immutable DTO representation of the entity data
 *//*from w ww .ja va2s  . c om*/
static Cluster toClusterDto(final ClusterEntity clusterEntity) {
    final Cluster.Builder builder = new Cluster.Builder(clusterEntity.getName(), clusterEntity.getUser(),
            clusterEntity.getVersion(), clusterEntity.getStatus()).withId(clusterEntity.getUniqueId())
                    .withCreated(clusterEntity.getCreated()).withUpdated(clusterEntity.getUpdated())
                    .withTags(
                            clusterEntity.getTags().stream().map(TagEntity::getTag).collect(Collectors.toSet()))
                    .withConfigs(clusterEntity.getConfigs().stream().map(FileEntity::getFile)
                            .collect(Collectors.toSet()))
                    .withDependencies(clusterEntity.getDependencies().stream().map(FileEntity::getFile)
                            .collect(Collectors.toSet()));

    clusterEntity.getDescription().ifPresent(builder::withDescription);
    clusterEntity.getSetupFile().ifPresent(setupFileEntity -> builder.withSetupFile(setupFileEntity.getFile()));
    setDtoMetadata(builder, clusterEntity);

    return builder.build();
}

From source file:enmasse.broker.prestop.TopicMigrator.java

private Set<Host> otherHosts() {
    return destinationBrokers.stream().filter(host -> !host.equals(localHost)).collect(Collectors.toSet());
}

From source file:com.openthinks.webscheduler.model.security.User.java

public Set<Role> getRoles() {
    if ((this.roles == null || this.roles.isEmpty()) && this.roleKeys != null) {
        try {//from   w w  w .  j av a2 s.com
            this.roles = this.roleKeys.getRoles().stream().map((roleKey) -> {
                Role role = null;
                Roles roles = WebContexts.get().lookup(WebSecurityService.class).getRoles();
                if (roleKey.getId() != null) {
                    role = roles.findById(roleKey.getId());
                }
                if (role == null && roleKey.getName() != null) {
                    role = roles.findByName(roleKey.getName());
                }
                Checker.require(role).notNull();
                return role;
            }).collect(Collectors.toSet());
        } catch (Exception e) {
            ProcessLogger.error(e);
            this.roles = Collections.emptySet();
        }
    }
    return roles;
}

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

@Override
public Set<ApplicationEntity> findByUser(String username) {
    try {/*from  w  ww.j av  a 2s .c om*/
        LOGGER.debug("Find applications for user {}", username);

        final Set<Application> applications = applicationRepository.findByUser(username, null);

        if (applications == null || applications.isEmpty()) {
            return emptySet();
        }

        final Set<ApplicationEntity> applicationEntities = new HashSet<>(applications.size());

        applicationEntities
                .addAll(applications.stream().map(ApplicationServiceImpl::convert).collect(Collectors.toSet()));

        return applicationEntities;
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to find applications for user {}", username, ex);
        throw new TechnicalManagementException(
                "An error occurs while trying to find applications for user " + username, ex);
    }
}