List of usage examples for java.util Collection stream
default Stream<E> stream()
From source file:io.gravitee.repository.mongodb.management.MongoEventRepository.java
private Set<Event> mapEvents(Collection<EventMongo> events) { return events.stream().map(this::mapEvent).collect(Collectors.toSet()); }
From source file:com.khartec.waltz.service.orgunit.OrganisationalUnitService.java
private List<FlatNode<OrganisationalUnit, Long>> toFlatNodes(Collection<OrganisationalUnit> allInvolvedUnits) { return allInvolvedUnits.stream().map(ou -> { Long ouId = ou.id().get(); Optional<Long> pid = ou.parentId(); return new FlatNode<>(ouId, pid, ou); }).collect(Collectors.toList()); }
From source file:org.openlmis.fulfillment.web.shipment.ShipmentDtoBuilder.java
/** * Create a new list of {@link ShipmentDto} based on data * from {@link Shipment}./* w w w. j av a2s . c o m*/ * * @param shipments collection used to create {@link ShipmentDto} list (can be {@code null}) * @return new list of {@link ShipmentDto}. Empty list if passed argument is {@code null}. */ public List<ShipmentDto> build(Collection<Shipment> shipments) { if (null == shipments) { return Collections.emptyList(); } return shipments.stream().map(this::export).collect(Collectors.toList()); }
From source file:org.openlmis.fulfillment.web.shipmentdraft.ShipmentDraftDtoBuilder.java
/** * Create a new list of {@link ShipmentDraftDto} based on data * from {@link ShipmentDraft}./*from w w w . ja va 2 s . c om*/ * * @param shipments collection used to create {@link ShipmentDraftDto} list (can be {@code null}) * @return new list of {@link ShipmentDraftDto}. Empty list if passed argument is {@code null}. */ public List<ShipmentDraftDto> build(Collection<ShipmentDraft> shipments) { if (null == shipments) { return Collections.emptyList(); } return shipments.stream().map(this::export).collect(Collectors.toList()); }
From source file:com.github.horrorho.inflatabledonkey.cloud.Donkey.java
Set<ByteString> anyChunks(Collection<ChunkInfo> chunks) { return chunks.stream().map(chunkInfo -> chunkInfo.getChunkChecksum()) .filter(checksum -> store.contains(checksum.toByteArray())).collect(toSet()); }
From source file:io.gravitee.gateway.handlers.api.policy.security.PlanBasedSecurityProviderFilter.java
@Override public List<SecurityProvider> filter(List<SecurityProvider> securityProviders) { logger.debug("Filtering security providers according to published API's plans"); List<SecurityProvider> providers = new ArrayList<>(); // Look into all plans for required authentication providers. Collection<Plan> plans = api.getPlans(); securityProviders.stream().forEach(provider -> { Optional<Plan> first = plans.stream() .filter(plan -> provider.name().equalsIgnoreCase(plan.getSecurity())).findFirst(); if (first.isPresent()) { logger.debug("Security provider [{}] is required by, at least, one plan. Installing...", provider.name());//from w w w. j ava2 s. c o m providers.add(new PlanBasedSecurityProvider(provider, first.get().getId())); } }); if (!providers.isEmpty()) { logger.info("API [{} ({})] requires the following security providers:", api.getName(), api.getVersion()); providers.stream() .forEach(authenticationProvider -> logger.info("\t* {}", authenticationProvider.name())); } else { logger.warn("No security provider is provided for API [{} ({})]", api.getName(), api.getVersion()); } return providers; }
From source file:de.wpsverlinden.dupfind.OutputPrinter.java
void printDupesOf(FileEntry info, Collection<FileEntry> dupes) { if (dupes.size() > 0) { println("-----\n" + info); dupes.stream().forEach((e) -> println(e.toString())); println("-----\n"); } else {/*w w w .j a v a2 s .co m*/ println("No dupes found."); } }
From source file:ru.anr.base.BaseParent.java
/** * A short-cut function to simplify the process of building a map from a * collection when there can be non-unique keys. * //from www .j a v a2s. c om * @param collection * An original collection * @param keyMapper * A key mapper * @param valueMapper * A value mapper * @param mergeFunction * A function to merge values conflicting by their key * @return A new map * * @param <T> * The type of a collection item * @param <K> * Type of the map key * @param <U> * Type of the map value */ public static <T, K, U> Map<K, U> toMap(Collection<T> collection, Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, BinaryOperator<U> mergeFunction) { return collection.stream().collect(Collectors.toConcurrentMap(keyMapper, valueMapper, mergeFunction)); }
From source file:com.thoughtworks.go.server.service.plugins.builder.DefaultPluginInfoFinder.java
public Collection<CombinedPluginInfo> allPluginInfos(String type) { if (isBlank(type)) { return builders.values().stream() .map((Function<MetadataStore, Collection<? extends PluginInfo>>) MetadataStore::allPluginInfos) .flatMap(// w w w . j av a 2 s . com (Function<Collection<? extends PluginInfo>, Stream<? extends PluginInfo>>) Collection::stream) .collect(Collectors.groupingBy(pluginID(), toCollection(CombinedPluginInfo::new))).values(); } else if (builders.containsKey(type)) { Collection<PluginInfo> pluginInfosForType = builders.get(type).allPluginInfos(); return pluginInfosForType.stream().map(CombinedPluginInfo::new).collect(toList()); } else { throw new InvalidPluginTypeException(); } }
From source file:de.wpsverlinden.dupfind.DupeRemover.java
public void deleteDupes(Collection<FileEntry> dupes, FileEntry info) { if (dupes.size() > 0) { outputPrinter.println("Deleting dupes of " + info); dupes.stream().map((e) -> e.getPath()).forEach((e) -> { File del = new File(userDir + e); fileIndex.remove(e);//from w ww . ja va 2 s .co m del.delete(); }); outputPrinter.println(" done."); } }