Example usage for java.util.stream StreamSupport stream

List of usage examples for java.util.stream StreamSupport stream

Introduction

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

Prototype

public static <T> Stream<T> stream(Spliterator<T> spliterator, boolean parallel) 

Source Link

Document

Creates a new sequential or parallel Stream from a Spliterator .

Usage

From source file:com.davidmogar.alsa.services.schedule.internal.ScheduleManagerServiceImpl.java

@Override
public List<ScheduleDto> findAll() {
    return StreamSupport.stream(scheduleDataService.findAll().spliterator(), false).map(ScheduleDto::new)
            .collect(Collectors.toList());
}

From source file:eu.itesla_project.dymola.DymolaAdaptersMatParamsWriter.java

public DymolaAdaptersMatParamsWriter(HierarchicalINIConfiguration configuration) {
    if (configuration == null) {
        throw new RuntimeException("null config");
    }//from  ww w  . j a va 2s .  c o m
    this.configuration = configuration;
    //this below will simply log parameters ..
    for (String section : configuration.getSections()) {
        SubnodeConfiguration node = configuration.getSection(section);
        List<String> paramsSummary = StreamSupport
                .stream(Spliterators.spliteratorUnknownSize(node.getKeys(), Spliterator.ORDERED), false)
                .map(p -> p + "=" + node.getString(p)).collect(Collectors.<String>toList());
        LOGGER.info("index {}: {}", section, paramsSummary);
    }
}

From source file:org.janusgraph.example.JanusGraphAppTest.java

@Test
public void createSchema() throws ConfigurationException {
    final JanusGraphApp app = new JanusGraphApp(CONF_FILE);
    final GraphTraversalSource g = app.openGraph();
    app.createSchema();/*  w  w w . j  a v a 2s  .  com*/
    final JanusGraph janusGraph = (JanusGraph) g.getGraph();
    final JanusGraphManagement management = janusGraph.openManagement();

    final List<String> vertexLabels = StreamSupport.stream(management.getVertexLabels().spliterator(), false)
            .map(Namifiable::name).collect(Collectors.toList());
    final List<String> expectedVertexLabels = Stream
            .of("titan", "location", "god", "demigod", "human", "monster").collect(Collectors.toList());
    assertTrue(vertexLabels.containsAll(expectedVertexLabels));

    final List<String> edgeLabels = StreamSupport
            .stream(management.getRelationTypes(EdgeLabel.class).spliterator(), false).map(Namifiable::name)
            .collect(Collectors.toList());
    final List<String> expectedEdgeLabels = Stream.of("father", "mother", "brother", "pet", "lives", "battled")
            .collect(Collectors.toList());
    assertTrue(edgeLabels.containsAll(expectedEdgeLabels));

    final EdgeLabel father = management.getEdgeLabel("father");
    assertTrue(father.isDirected());
    assertFalse(father.isUnidirected());
    assertEquals(Multiplicity.MANY2ONE, father.multiplicity());

    final List<String> propertyKeys = StreamSupport
            .stream(management.getRelationTypes(PropertyKey.class).spliterator(), false).map(Namifiable::name)
            .collect(Collectors.toList());
    final List<String> expectedPropertyKeys = Stream.of("name", "age", "time", "place", "reason")
            .collect(Collectors.toList());
    assertTrue(propertyKeys.containsAll(expectedPropertyKeys));

    final PropertyKey place = management.getPropertyKey("place");
    assertEquals(Cardinality.SINGLE, place.cardinality());
    assertEquals(Geoshape.class, place.dataType());

    final JanusGraphIndex nameIndex = management.getGraphIndex("nameIndex");
    assertTrue(nameIndex.isCompositeIndex());
    assertTrue(nameIndex.getIndexedElement().equals(JanusGraphVertex.class));
    final PropertyKey[] nameIndexKeys = nameIndex.getFieldKeys();
    assertEquals(1, nameIndexKeys.length);
    assertEquals("name", nameIndexKeys[0].name());
}

From source file:com.davidmogar.alsa.services.bus.internal.BusManagerServiceImpl.java

@Override
public List<BusDto> findByLicensePlateLike(String licensePlate) {
    return StreamSupport
            .stream(busDataService.findByLicensePlateLike("%" + licensePlate + "%").spliterator(), false)
            .map(BusDto::new).collect(Collectors.toList());
}

From source file:org.n52.iceland.config.json.AbstractJsonDao.java

protected Stream<Entry<String, JsonNode>> createEntryStream(JsonNode node) {
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(node.fields(), 0), true);
}

From source file:it.polimi.diceH2020.launcher.FileService.java

public Stream<Path> getBaseSolutionsPath() {
    String strDir = settings.getSolInstanceDir();
    Path dir = FileSystems.getDefault().getPath(strDir);
    if (Files.notExists(dir)) {
        Path currentRelativePath = Paths.get("");
        dir = FileSystems.getDefault()
                .getPath(currentRelativePath.toAbsolutePath().toString() + File.pathSeparator + strDir);
    }/*from w w w  .  ja  v a2  s.  c  om*/
    DirectoryStream<Path> stream;
    try {
        stream = Files.newDirectoryStream(dir, "*.{json}");
        return StreamSupport.stream(stream.spliterator(), false);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
    }
}

From source file:org.bozzo.ipplan.domain.model.ui.ZoneResource.java

/**
 * @param id/*  w w  w  .ja  v a 2s .c o  m*/
 * @param infraId
 * @param ip
 * @param description
 */
@JsonCreator
public ZoneResource(@JsonProperty("id") Long id, @JsonProperty Integer infraId, @JsonProperty Long ip,
        @JsonProperty String description, @JsonProperty Iterable<Range> ranges) {
    super();
    this.id = id;
    this.infraId = infraId;
    this.ip = ip;
    this.description = description;
    if (ranges != null) {
        this.setRanges(StreamSupport.stream(ranges.spliterator(), true).map(new ToRangeResourceFunction()));
    }
}

From source file:com.avanza.ymer.MongoDocumentCollection.java

@Override
public Stream<DBObject> findByTemplate(BasicDBObject query) {
    return StreamSupport.stream(dbCollection.find(query).spliterator(), false);
}

From source file:com.cloudera.oryx.common.text.TextUtils.java

private static String[] doParseDelimited(String delimited, CSVFormat format) {
    try (CSVParser parser = CSVParser.parse(delimited, format)) {
        Iterator<CSVRecord> records = parser.iterator();
        return records.hasNext()
                ? StreamSupport.stream(records.next().spliterator(), false).toArray(String[]::new)
                : EMPTY_STRING;/*from  w  w  w. j  a  v  a  2s .c om*/
    } catch (IOException e) {
        throw new IllegalStateException(e); // Can't happen
    }
}

From source file:edu.umd.umiacs.clip.tools.io.GZIPFiles.java

protected static Stream<CSVRecord> records(CSVFormat format, Path path) throws IOException {
    return StreamSupport.stream(format.parse(new BufferedReader(new InputStreamReader(
            new GZIPInputStream(new BufferedInputStream(newInputStream(path), BUFFER_SIZE)),
            UTF_8.newDecoder().onMalformedInput(IGNORE)))).spliterator(), false);
}