Example usage for java.util SortedSet stream

List of usage examples for java.util SortedSet stream

Introduction

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

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:org.eclipse.winery.tools.copybaragenerator.CopybaraGenerator.java

public String generateOriginFilesConfig() {
    SortedSet<DefinitionsChildId> allDefinitionsChildIds = repository.getAllDefinitionsChildIds();
    return allDefinitionsChildIds.stream().filter(id -> {
        RepositoryFileReference repositoryFileReference = new RepositoryFileReference(id,
                Constants.LICENSE_FILE_NAME);
        if (!repository.exists(repositoryFileReference)) {
            return false;
        }//from  www . j  a va  2s.  c  o  m
        try (InputStream inputStream = repository.newInputStream(repositoryFileReference)) {
            // we put the whole license file text into a string and check if it starts with "Apache License" after
            // trimming it
            final String licenceString = "Apache License";
            String fileAsString = IOUtils.toString(inputStream);

            return fileAsString.trim().startsWith(licenceString);
        } catch (IOException e) {
            LOGGER.error("Could not create input stream for {}", repositoryFileReference.toString(), e);
            return false;
        }
    }).map(id -> BackendUtils.getPathInsideRepo(id)).collect(Collectors.joining("**\",\n        \"",
            "origin_files = glob([\"README.md\", \"LICENSE\", \"", "**\"]),"));
}

From source file:org.sonar.java.se.JavaCheckVerifier.java

private void assertSoleFlowDiscrepancy(String expectedId, List<AnalyzerMessage> actualFlow) {
    SortedSet<Expectations.FlowComment> expected = expectations.flows.get(expectedId);
    List<Integer> expectedLines = expected.stream().map(f -> f.line).collect(Collectors.toList());
    List<Integer> actualLines = actualFlow.stream().map(AnalyzerMessage::getLine).collect(Collectors.toList());
    assertThat(actualLines).as("Flow " + expectedId + " has line differences").isEqualTo(expectedLines);
}

From source file:org.sonar.java.se.JavaCheckVerifier.java

private void validateFlowMessages(List<AnalyzerMessage> actual, String flowId,
        SortedSet<Expectations.FlowComment> expected) {
    List<String> actualMessages = actual.stream().map(AnalyzerMessage::getMessage).collect(Collectors.toList());
    List<String> expectedMessages = expected.stream().map(Expectations.FlowComment::message)
            .collect(Collectors.toList());

    replaceExpectedNullWithActual(actualMessages, expectedMessages);

    assertThat(actualMessages)/*  w  w  w.ja  v  a 2  s  .  c o  m*/
            .as("Wrong messages in flow " + flowId + " [" + expectations.flowToLines(flowId) + "]")
            .isEqualTo(expectedMessages);
}