List of usage examples for java.util.stream Collectors toSet
public static <T> Collector<T, ?, Set<T>> toSet()
From source file:com.netflix.spinnaker.fiat.providers.DefaultServiceAccountProvider.java
@Override public Set<ServiceAccount> getAllRestricted(@NonNull Set<Role> roles) throws ProviderException { List<String> roleNames = roles.stream().map(Role::getName).collect(Collectors.toList()); return getAll().stream().filter(svcAcct -> !svcAcct.getMemberOf().isEmpty()) .filter(svcAcct -> roleNames.containsAll(svcAcct.getMemberOf())).collect(Collectors.toSet()); }
From source file:com.vsct.dt.strowgr.admin.repository.consul.mapping.json.EntryPointMappingJson.java
public EntryPointMappingJson(EntryPoint entryPoint) { this(entryPoint.getHaproxy(), entryPoint.getHapUser(), entryPoint.getHapVersion(), entryPoint.getBindingId(),/* ww w. j a v a2 s . c o m*/ entryPoint.getFrontends().stream().map(EntryPointFrontendMappingJson::new) .collect(Collectors.toSet()), entryPoint.getBackends().stream().map(EntryPointBackendMappingJson::new) .collect(Collectors.toSet()), entryPoint.getContext()); }
From source file:com.example.oauth.AccessToken.java
@Override public Set<String> getScope() { return scopes.stream().map(Scope::asString).collect(Collectors.toSet()); }
From source file:io.gravitee.repository.redis.management.internal.impl.ApplicationRedisRepositoryImpl.java
@Override public Set<RedisApplication> find(List<String> applicationIds) { return redisTemplate.opsForHash().multiGet(REDIS_KEY, Collections.unmodifiableCollection(applicationIds)) .stream().map(o -> this.convert(o, RedisApplication.class)).collect(Collectors.toSet()); }
From source file:org.createnet.raptor.auth.service.services.UserService.java
/** * Save new roles or load roles based on name to ensure roles are all managed *///from w ww . j a v a 2 s . co m protected void saveRoles(User user) { user.setRoles(user.getRoles().stream().map((r) -> { if (r.getId() != null) { return r; } Role r1 = roleRepository.findByName(r.getName()); if (r1 != null) { return r1; } r = roleRepository.save(r); return r; }).collect(Collectors.toSet())); }
From source file:io.gravitee.management.service.impl.PolicyServiceImpl.java
@Override public Set<PolicyEntity> findAll() { try {// w w w . j a v a2 s . c om LOGGER.debug("List all policies"); final Collection<PolicyPlugin> policyDefinitions = policyManager.findAll(); return policyDefinitions.stream().map(policyDefinition -> convert(policyDefinition, false)) .collect(Collectors.toSet()); } catch (Exception ex) { LOGGER.error("An error occurs while trying to list all policies", ex); throw new TechnicalManagementException("An error occurs while trying to list all policies", ex); } }
From source file:ddf.catalog.validation.impl.validator.EnumerationValidator.java
/** * Constructs an {@code EnumerationValidator} with a given set of acceptable values. * * @param values the values accepted by this validator * @throws IllegalArgumentException if {@code values} is null or empty */// w w w .j a v a2 s.c o m public EnumerationValidator(final Set<String> values) { Preconditions.checkArgument(CollectionUtils.isNotEmpty(values), "Must specify at least one possible enumeration value."); this.values = values.stream().filter(Objects::nonNull).collect(Collectors.toSet()); }
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:com.github.anba.es6draft.test262.Test262Strict.java
public static final Set<String> stringSet(List<?> xs) { Predicate<String> nonEmpty = ((Predicate<String>) String::isEmpty).negate(); return xs.stream().filter(Objects::nonNull).map(Object::toString).filter(nonEmpty) .collect(Collectors.toSet()); }
From source file:org.openlmis.fulfillment.service.ShipmentService.java
/** * Saves the given shipment to database. Also related Proof Of Delivery will be created. *///from www . ja v a 2s . c o m public Shipment save(final Shipment shipment) { Shipment saved = shipmentRepository.save(shipment); Set<UUID> orderableIds = saved.getLineItems().stream().map(ShipmentLineItem::getOrderableId) .collect(Collectors.toSet()); Map<UUID, Boolean> useVvm = orderableReferenceDataService.findByIds(orderableIds).stream() .collect(Collectors.toMap(BaseDto::getId, OrderableDto::useVvm)); ProofOfDelivery proofOfDelivery = ProofOfDelivery.newInstance(saved, useVvm); proofOfDeliveryRepository.save(proofOfDelivery); return saved; }