Example usage for java.util Collection stream

List of usage examples for java.util Collection stream

Introduction

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

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:it.unibo.alchemist.model.implementations.conditions.BiomolPresentInNeighbor.java

@Override
public Map<Node<Double>, Double> getValidNeighbors(final Collection<? extends Node<Double>> neighborhood) {
    propensity = 0;/*from  w w w. j ava  2 s . c  o m*/
    neigh = neighborhood.stream().filter(n -> n instanceof CellNode && n.getConcentration(mol) >= conc)
            .collect(Collectors.<Node<Double>, Node<Double>, Double>toMap(n -> n, n -> CombinatoricsUtils
                    .binomialCoefficientDouble(n.getConcentration(mol).intValue(), conc.intValue())));
    if (!neigh.isEmpty()) {
        propensity = neigh.values().stream().max((d1, d2) -> d1.compareTo(d2)).get();
    }
    return new LinkedHashMap<>(neigh);
}

From source file:de.metas.ui.web.window.datatypes.json.JSONDocumentReferencesList.java

private JSONDocumentReferencesList(final Collection<DocumentReference> documentReferences,
        final JSONOptions jsonOpts) {
    super();//from   ww  w .  j a  v a  2  s  .c  o  m
    references = documentReferences.stream()
            .map(documentReference -> JSONDocumentReference.of(documentReference, jsonOpts))
            .filter(jsonDocumentReference -> jsonDocumentReference != null)
            .collect(GuavaCollectors.toImmutableList());
}

From source file:com.vmware.photon.controller.deployer.configuration.ServiceConfigurator.java

public void applyDynamicParameters(String mustacheDir, ContainersConfig.ContainerType containerType,
        final Map<String, ?> dynamicParameters) {
    File configDir = new File(mustacheDir, ServiceFileConstants.CONTAINER_CONFIG_ROOT_DIRS.get(containerType));
    Collection<File> files = FileUtils.listFiles(configDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    files.stream().forEach(file -> applyMustacheParameters(file, dynamicParameters));
}

From source file:com.paytmlabs.hazelcast.mapstore.HazelcastMapStore.java

@Override
public void deleteAll(final Collection<K> keys) {

    keys.stream().forEach((key) -> {
        delete(key);
    });

}

From source file:com.github.horrorho.inflatabledonkey.cloud.AuthorizeAssets.java

List<CloudKit.Asset> ckAssets(Collection<Asset> assets) {
    return assets.stream().map(Asset::asset).filter(Optional::isPresent).map(Optional::get)
            .collect(Collectors.toList());
}

From source file:com.github.horrorho.inflatabledonkey.cloud.AuthorizeAssets.java

Map<ByteString, List<Asset>> downloadables(Collection<Asset> assets) {
    return assets.stream().filter(this::isDownloadable)
            .collect(Collectors.groupingBy(a -> ByteString.copyFrom(a.fileSignature().get())));
}

From source file:ru.anr.base.BaseParent.java

/**
 * A short-cut method for simple mapping from a collection to a map
 * /*w ww  .j  a va  2s . co m*/
 * @param collection
 *            A collection
 * @param keyMapper
 *            A key mapper
 * @param valueMapper
 *            A value mapper
 * @return A new created map
 * 
 * @param <T>
 *            The type of collection items
 * @param <K>
 *            The type of map keys
 * @param <U>
 *            The type of map values
 */
public static <T, K, U> Map<K, U> toMap(Collection<T> collection, Function<? super T, ? extends K> keyMapper,
        Function<? super T, ? extends U> valueMapper) {

    return collection.stream().collect(Collectors.toMap(keyMapper, valueMapper));
}

From source file:org.openlmis.fulfillment.web.util.ProofOfDeliveryDtoBuilder.java

/**
 * Create a new list of {@link ProofOfDeliveryDto} based on data
 * from {@link Shipment}./*w ww  . j  a  v a  2 s.c  o m*/
 *
 * @param pods collection used to create {@link ProofOfDeliveryDto} list (can be {@code null})
 * @return new list of {@link ProofOfDeliveryDto}. Empty list if passed argument is {@code null}.
 */
public List<ProofOfDeliveryDto> build(Collection<ProofOfDelivery> pods) {
    if (null == pods) {
        return Collections.emptyList();
    }
    return pods.stream().map(this::export).collect(Collectors.toList());
}

From source file:com.github.yongchristophertang.engine.web.http.MultipartBodyFormBuilder.java

public MultipartBodyFormBuilder param(String name, Collection<String> values) {
    AssertUtils.notNull(name, "Parameter name must not be null.");
    values.stream().forEach(v -> builder.addTextBody(name, v, ContentType.TEXT_PLAIN));
    return this;
}

From source file:io.pivotal.cla.data.repository.CorporateSignatureRepository.java

default List<CorporateSignature> findSignatures(PageRequest pageable, Collection<String> organizations,
        Collection<String> emails) {
    List<String> emailDomains = emails == null || emails.isEmpty() ? EMPTY_LIST_FOR_QUERY
            : emails.stream().map(e -> e.substring(e.lastIndexOf("@") + 1)).collect(Collectors.toList());
    organizations = organizations.isEmpty() ? EMPTY_LIST_FOR_QUERY : organizations;
    return findSignaturesByOrganizationsAndEmailDomains(pageable, organizations, emailDomains);
}