Example usage for java.util.stream Collectors toList

List of usage examples for java.util.stream Collectors toList

Introduction

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

Prototype

public static <T> Collector<T, ?, List<T>> toList() 

Source Link

Document

Returns a Collector that accumulates the input elements into a new List .

Usage

From source file:cz.muni.fi.editor.database.test.helpers.AbstractDAOTest.java

protected static void checkMethods(Class testClass, Class testingInterface) {
    Set<String> testMethods = new HashSet<>();
    for (Method m : testClass.getDeclaredMethods()) {
        if (m.isAnnotationPresent(Test.class)) {
            testMethods.add(m.getName());
        }//  w w  w.  java2s.  c o m
    }

    List<String> targetMethods = new ArrayList<>(
            Arrays.asList("create", "update", "getById", "delete", "getAll", "getClassType"));
    targetMethods.addAll(new ArrayList<>(Arrays.asList(testingInterface.getDeclaredMethods())).stream()
            .map(m -> m.getName()).collect(Collectors.toList()));
    testMethods.forEach(targetMethods::remove);

    Assert.assertEquals("Following method(s) are missing in DAO test :" + targetMethods.toString(), 0,
            targetMethods.size());
}

From source file:org.mybatis.spring.boot.autoconfigure.SpringBootVFS.java

@Override
protected List<String> list(URL url, String path) throws IOException {
    Resource[] resources = resourceResolver.getResources("classpath*:" + path + "/**/*.class");
    return Stream.of(resources).map(resource -> preserveSubpackageName(resource, path))
            .collect(Collectors.toList());
}

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());
}

From source file:org.travis4j.model.json.LogJsonObject.java

@Override
public Stream<String> getBody() {
    if (cache != null) {
        return cache.stream();
    }//from  ww w .  ja  va2 s  .  c om

    if (body == null) {
        return null;
    }
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(body.getContent()))) {
        cache = reader.lines().collect(Collectors.toList());
        return cache.stream();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.twosigma.beakerx.security.HashedMessageAuthenticationCode.java

public String sign(List<String> msg) {
    List<byte[]> collect = msg.stream().map(x -> x.getBytes(StandardCharsets.UTF_8))
            .collect(Collectors.toList());
    return signBytes(collect);
}

From source file:com.hubrick.vertx.s3.signature.AWS4SignatureBuilderTest.java

@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> getBasenames() {
    return TESTCASES.stream().map(testcase -> new Object[] { testcase }).collect(Collectors.toList());
}

From source file:com.adobe.acs.commons.mcp.util.ValueMapSerializer.java

public static String[] serializeToStringArray(Object value) {
    if (value == null) {
        return new String[0];
    } else if (value instanceof String[]) {
        return (String[]) value;
    } else if (value.getClass().isArray()) {
        List<String> values = (List) Arrays.asList((Object[]) value).stream().map(String::valueOf)
                .collect(Collectors.toList());
        return (String[]) values.toArray(new String[0]);
    } else if (value instanceof Collection) {
        List<String> values = (List) ((Collection) value).stream().map(String::valueOf)
                .collect(Collectors.toList());
        return (String[]) values.toArray(new String[0]);
    } else {//  w  w  w .  j  a  va2s . c o m
        return new String[] { value.toString() };
    }
}

From source file:uk.ac.ebi.ep.data.repositories.EnzymePortalPathwaysRepositoryImpl.java

@Transactional(readOnly = true)
@Override//w  w w.  j a v  a2  s.  co m
public List<String> findAccessionsByPathwayId(String pathwayId) {

    List<String> enzymes = new ArrayList<>();
    JPAQuery query = new JPAQuery(entityManager);

    List<EnzymePortalPathways> entries = query.from($).where($.pathwayId.equalsIgnoreCase(pathwayId)).distinct()
            .list($).stream().distinct().collect(Collectors.toList());

    entries.stream().forEach(e -> {
        enzymes.add(e.getUniprotAccession().getAccession());
    });

    return enzymes;

}

From source file:net.sf.jabref.model.entry.CustomEntryType.java

public CustomEntryType(String name, List<String> required, List<String> primaryOptional,
        List<String> secondaryOptional) {
    this.name = EntryUtil.capitalizeFirst(name);
    this.primaryOptional = primaryOptional;
    this.required = required;
    this.optional = Stream.concat(primaryOptional.stream(), secondaryOptional.stream())
            .collect(Collectors.toList());
}