Example usage for java.util List stream

List of usage examples for java.util List stream

Introduction

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

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:beyondlambdas.slides.s8_1.Support.java

public static Stream<String> badJsonData() {
    final List<Integer> integers = IntStream.rangeClosed(1, 20).boxed().collect(toList());
    integers.set(12, 21);//from   w ww.ja v  a2s . com
    return integers.stream().map(Support::item);
}

From source file:alfio.manager.plugin.PluginManager.java

private static <T extends Plugin> Stream<T> filterPlugins(List<Plugin> plugins, int eventId, Class<T> type) {
    return plugins.stream().filter(type::isInstance).filter(p -> p.isEnabled(eventId)).map(type::cast);
}

From source file:com.baifendian.swordfish.common.job.struct.node.BaseParam.java

/**
 * @param resourceInfos//  www  .ja  v a 2 s.  com
 * @param resFiles
 */
public static void addProjectResourceFiles(List<ResourceInfo> resourceInfos, List<String> resFiles) {
    if (CollectionUtils.isNotEmpty(resourceInfos)) {
        resFiles.addAll(resourceInfos.stream().filter(p -> p.isProjectScope()).map(p -> p.getRes())
                .collect(Collectors.toList()));
    }
}

From source file:com.ginema.api.reflection.ReflectionUtils.java

public static Stream<Field> getAnnotatedFields(Object a, Class annotation) {
    List<Field> declaredFields = new LinkedList<>(Arrays.asList(a.getClass().getDeclaredFields()));
    return declaredFields.stream().filter(p -> p.getAnnotation(annotation) != null);

}

From source file:demo.support.NavUtils.java

public static String encodePolyline(List<Point> points) {
    final List<LatLng> latLngs = points.stream()
            .map(point -> new LatLng(point.getLatitude(), point.getLongitude())).collect(Collectors.toList());
    return PolylineEncoding.encode(latLngs);
}

From source file:alfio.model.modification.EventWithStatistics.java

private static int countSoldTickets(List<TicketCategoryWithStatistic> ticketCategories) {
    return ticketCategories.stream().mapToInt(TicketCategoryWithStatistic::getSoldTickets).sum();
}

From source file:com.vmware.photon.controller.api.frontend.utils.SecurityGroupUtils.java

/**
 * Transform a list of security group entities to api representation.
 *
 * @param entities List of security group entities.
 * @return List of security groups.//from  ww  w.  j  ava 2 s  . co  m
 */
public static List<SecurityGroup> toApiRepresentation(List<SecurityGroupEntity> entities) {
    return entities.stream().map(entity -> toApiRepresentation(entity)).collect(Collectors.toList());
}

From source file:com.vmware.photon.controller.api.frontend.utils.SecurityGroupUtils.java

/**
 * Transform a list of security groups to internal entity representation.
 *
 * @param securityGroups List of security groups.
 * @return List of security group entities.
 *//*  w  w w.ja  v a 2s . co m*/
public static List<SecurityGroupEntity> fromApiRepresentation(List<SecurityGroup> securityGroups) {
    return securityGroups.stream().map(sg -> fromApiRepresentation(sg)).collect(Collectors.toList());
}

From source file:ch.sdi.core.impl.data.converter.ConverterNumberList.java

public static List<Long> toLongList(String aStringArray, String aDelimiter) throws SdiException {
    List<Long> result = new ArrayList<Long>();

    List<Number> list = toList(aStringArray, aDelimiter);
    list.stream().forEach(n -> result.add(n.longValue()));

    return result;
}

From source file:ddf.catalog.transformer.csv.common.CsvTransformer.java

/**
 * Given a list of {@link Metacard}s, returns a set of {@link AttributeDescriptor}s that contains
 * all attributes that exist on the given metacard types. Object and Binary types are excluded
 *
 * @param metacards List of metacards from which to extract attribute descriptors
 * @return a Set of {@AttributeDescriptor}s that are on each metacard
 *///from  w w w  .  j a v a2  s.  c o  m
public static Set<AttributeDescriptor> getAllCsvAttributeDescriptors(final List<Metacard> metacards) {

    return metacards.stream().filter(Objects::nonNull).map(Metacard::getMetacardType)
            .map(MetacardType::getAttributeDescriptors).flatMap(Set::stream)
            .filter(CsvTransformer::attributeNotBinary).filter(CsvTransformer::attributeNotObject)
            .collect(toSet());
}