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:Main.java

public static <T> String getCommaSeparatedNames(List<T> list, Function<T, String> function) {
    return list.stream().map(function).collect(Collectors.joining(","));
}

From source file:Main.java

public static <T> boolean contains(List<T> toFilter, Predicate<T> predicate) {
    return toFilter.stream().anyMatch(predicate);
}

From source file:Main.java

public static <T, R> List<R> map(List<T> list, Function<T, R> fun) {
    return list.stream().map(fun::apply).collect(Collectors.toList());
}

From source file:Main.java

public static <T, R> List<R> apply(List<T> list, Function<T, R> mapper) {
    return list.stream().map(mapper).collect(Collectors.toList());
}

From source file:com.kazuki43zoo.apistub.domain.model.KeyGeneratingStrategy.java

public static <T> String join(List<T> keys) {
    return keys.stream().map(e -> e == null ? "" : e.toString()).collect(Collectors.joining(KEY_DELIMITER));
}

From source file:Main.java

/**
 * Converts a List of Integers to an integer array.
 * /*from  w w  w  . j  ava  2  s .com*/
 * @param integerList List of Integers
 * @return integer array
 */
public static int[] intListToArray(final List<Integer> integerList) {
    return integerList.stream().mapToInt(value -> value).toArray();
}

From source file:edu.umd.umiacs.clip.tools.math.Formatter.java

public static List<Double> format(List<Double> list) {
    return list.stream().map(Formatter::format).collect(toList());
}

From source file:Main.java

public static <T> List<T> merge(List<List<T>> list) {
    List<T> result = new ArrayList<>();
    list.stream().forEach(result::addAll);
    return result;
}

From source file:Main.java

public static <T> BigDecimal reduce(List<T> list, Function<T, BigDecimal> mapToBigdecimalFunction) {
    return list.stream().map(mapToBigdecimalFunction).reduce(ZERO, (l, r) -> l.add(r));
}

From source file:ch.ge.ve.protopoc.jwt.JwtUserFactory.java

private static List<GrantedAuthority> mapToGrantedAuthorities(List<Authority> authorities) {
    return authorities.stream().map(authority -> new SimpleGrantedAuthority(authority.getName().name()))
            .collect(Collectors.toList());
}