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:io.knotx.junit.util.KnotContextFactory.java

public static KnotContext create(List<Pair<List<String>, String>> fragments) {
    return new KnotContext()
            .setFragments(/*from   www.ja  va2 s  .co m*/
                    fragments != null
                            ? fragments.stream().map(data -> Fragment.snippet(data.getKey(), data.getValue()))
                                    .collect(Collectors.toList())
                            : null)
            .setClientRequest(new ClientRequest())
            .setClientResponse(new ClientResponse().setHeaders(MultiMap.caseInsensitiveMultiMap()));
}

From source file:br.com.elotech.karina.service.impl.LicenseServiceImpl.java

@Override
public List<License> processar() {

    return this.integracaoRepository.findAll().stream().map(this::getLicenseFrom).collect(Collectors.toList());
}

From source file:org.apache.nifi.minifi.integration.util.LogUtil.java

public static void verifyLogEntries(String expectedJsonFilename, Container container) throws Exception {
    List<ExpectedLogEntry> expectedLogEntries;
    try (InputStream inputStream = LogUtil.class.getClassLoader().getResourceAsStream(expectedJsonFilename)) {
        List<Map<String, Object>> expected = new ObjectMapper().readValue(inputStream, List.class);
        expectedLogEntries = expected.stream()
                .map(map -> new ExpectedLogEntry(Pattern.compile((String) map.get("pattern")),
                        (int) map.getOrDefault("occurrences", 1)))
                .collect(Collectors.toList());
    }/*  w  w w. ja va 2  s .  c o m*/
    DockerPort dockerPort = container.port(8000);
    URL url = new URL("http://" + dockerPort.getIp() + ":" + dockerPort.getExternalPort());
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    try (InputStream inputStream = urlConnection.getInputStream();
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
        String line;
        for (ExpectedLogEntry expectedLogEntry : expectedLogEntries) {
            boolean satisfied = false;
            int occurrences = 0;
            while ((line = bufferedReader.readLine()) != null) {
                if (expectedLogEntry.pattern.matcher(line).find()) {
                    logger.info("Found expected: " + line);
                    if (++occurrences >= expectedLogEntry.numOccurrences) {
                        logger.info("Found target " + occurrences + " times");
                        satisfied = true;
                        break;
                    }
                }
            }
            if (!satisfied) {
                fail("End of log reached without " + expectedLogEntry.numOccurrences + " match(es) of "
                        + expectedLogEntry.pattern);
            }
        }
    } finally {
        urlConnection.disconnect();
    }
}

From source file:org.obiba.mica.web.model.LocalizedStringDtos.java

Iterable<Mica.LocalizedStringDto> asDto(
        @SuppressWarnings("TypeMayBeWeakened") LocalizedString localizedString) {
    if (localizedString == null)
        return Collections.emptyList();
    return localizedString.entrySet().stream().map(entry -> Mica.LocalizedStringDto.newBuilder()
            .setLang(entry.getKey()).setValue(entry.getValue()).build()).collect(Collectors.toList());
}

From source file:org.obiba.mica.web.rest.LogsResource.java

@GET
@Produces(APPLICATION_JSON)//  w  ww . j  ava 2  s  . com
@Timed
public List<LoggerDTO> getList() {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    return context.getLoggerList().stream().map(LoggerDTO::new).collect(Collectors.toList());
}

From source file:org.moserp.common.converter.ListConverter.java

public List<T> convert(List<S> source) {
    return source.stream().map(converter::convert).collect(Collectors.toList());
}

From source file:svc.data.citations.datasources.tyler.transformers.CitationTransformer.java

public List<Citation> fromTylerCitations(List<TylerCitation> tylerCitations) {
    if (tylerCitations != null) {
        return tylerCitations.stream().map(tylerCitation -> fromTylerCitation(tylerCitation))
                .collect(Collectors.toList());
    }//  w  w w. j  a v a 2s  .co  m
    return null;
}

From source file:com.github.horrorho.liquiddonkey.util.Bytes.java

public static String hex(Collection<ByteString> byteStrings) {
    return byteStrings == null ? "null"
            : byteStrings.stream().map(Bytes::hex).collect(Collectors.toList()).toString();
}

From source file:com.firewallid.util.FIUtils.java

public static <L> List<Tuple2<L, Long>> reduceList(List<L> l) {
    List<Tuple2<L, Long>> listTuple = reduceListToMap(l).entrySet().parallelStream()
            .map(objectCount -> new Tuple2<>(objectCount.getKey(), objectCount.getValue()))
            .collect(Collectors.toList());

    return listTuple;
}