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:edu.pitt.dbmi.ccd.anno.group.GroupResourceAssembler.java

/**
 * convert Groups to GroupResources/* ww w.j  av a 2s .c  o  m*/
 *
 * @param groups entities
 * @return List of resources
 */
@Override
public List<GroupResource> toResources(Iterable<? extends Group> groups) throws IllegalArgumentException {
    // Assert groups is not empty
    Assert.isTrue(groups.iterator().hasNext());
    return StreamSupport.stream(groups.spliterator(), false).map(this::toResource).collect(Collectors.toList());
}

From source file:edu.pitt.dbmi.ccd.anno.vocabulary.VocabularyResourceAssembler.java

/**
 * convert Vocabularies to VocabularyResources
 *
 * @param vocabularies entities//from w w w  .  j a  v a 2  s  . c  o  m
 * @return List of resources
 */
@Override
public List<VocabularyResource> toResources(Iterable<? extends Vocabulary> vocabularies)
        throws IllegalArgumentException {
    // Assert vocabularies is not empty
    Assert.isTrue(vocabularies.iterator().hasNext());
    return StreamSupport.stream(vocabularies.spliterator(), false).map(this::toResource)
            .collect(Collectors.toList());
}

From source file:org.mskcc.shenkers.data.interval.GIntervalTreeMap.java

public Stream<Node<T>> streamOverlapNodes(String chr, int start, int end) {
    boolean parallel = false;
    int characteristics = 0;
    return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(queryNodes(chr, start, end), characteristics), parallel);
}

From source file:org.neo4j.helpers.json.document.impl.DocumentRelationBuilderByKey.java

@Override
public Relationship buildRelation(Node parent, Node child, DocumentRelationContext context) {
    String documentKey = context.getDocumentKey();
    if (StringUtils.isBlank(documentKey)) {
        return null;
    }//from  w w  w .  j  a v  a2s  . c  om

    RelationshipType relationType = RelationshipType.withName(documentKey);

    //check if already exists
    Iterable<Relationship> relationships = child.getRelationships(Direction.INCOMING, relationType);

    //find only relation between parent and child node
    List<Relationship> rels = StreamSupport.stream(relationships.spliterator(), false)
            .filter(rel -> rel.getStartNode().getId() == parent.getId()).collect(Collectors.toList());

    Relationship relationship;

    if (rels.isEmpty()) {
        relationship = parent.createRelationshipTo(child, relationType);
        if (log.isDebugEnabled())
            log.debug("Create new Relation " + relationship);
    } else {
        relationship = rels.get(0);
        if (log.isDebugEnabled())
            log.debug("Update Relation " + relationship);
    }

    return relationship;
}

From source file:com.wrmsr.wava.basic.BasicLoopInfo.java

public static SetMultimap<Name, Name> findBasicBackEdges(Iterable<Basic> basics, Set<Name> loops,
        BasicDominatorInfo di) {//from  ww w.  j  a  va2 s  . c  o  m
    return StreamSupport.stream(basics.spliterator(), false).flatMap(brk -> {
        Set<Name> bdf = di.getDominanceFrontiers().get(brk.getName());
        return brk.getAllTargets().stream()
                .filter(loop -> loops.contains(loop) && bdf.contains(loop)
                        && (loop.equals(brk.getName()) || di.getDominated(loop).contains(brk.getName())))
                .map(loop -> ImmutablePair.of(loop, brk.getName()));
    }).collect(toHashMultimap());
}

From source file:com.leadscope.commanda.sources.CSVSource.java

@Override
public Stream<CSVRecord> stream(InputStream inputStream) {
    try {//from  w  w  w . ja v  a 2  s  .  c  o  m
        CSVParser parser = new CSVParser(new InputStreamReader(inputStream, charset), format);
        return StreamSupport.stream(parser.spliterator(), false);
    } catch (RuntimeException re) {
        throw re;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.crossover.trial.weather.endpoint.RestWeatherQueryEndpoint.java

@RequestMapping(path = "/query/weather/{iata}/{radius}", method = GET, produces = "application/json")
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Bad Request") })
public List<Data> findInRange(@PathVariable("iata") IATA iata, @PathVariable("radius") double radius) {

    Assert.isTrue(iata != null);//from  w  w  w. j av a2 s  .c o m

    metricsService.markRequest(iata, radius);

    return StreamSupport.stream(airportRepository.findInRadius(iata, radius).spliterator(), false)
            .map(dataPointRepository::findLatestMeasurementForIata).filter(measurement -> measurement != null)
            .map(Data::new).collect(Collectors.toList());
}

From source file:edu.pitt.dbmi.ccd.db.service.GroupService.java

public List<Group> findByIds(Iterable<Long> ids) {
    return StreamSupport.stream(ids.spliterator(), false).map(this::findById).collect(Collectors.toList());
}

From source file:net.hamnaberg.json.Query.java

static List<Query> fromArray(JsonNode queries) {
    return Collections.unmodifiableList(StreamSupport.stream(queries.spliterator(), false)
            .map(jsonNode -> new Query((ObjectNode) jsonNode)).collect(Collectors.toList()));
}

From source file:edu.pitt.dbmi.ccd.anno.user.UserResourceAssembler.java

/**
 * Convert UserAccounts + Persons to UserResources
 *
 * @param accounts entities//  ww  w  .j av  a 2 s.  com
 * @return List of resources
 */
@Override
public List<UserResource> toResources(Iterable<? extends UserAccount> accounts)
        throws IllegalArgumentException {
    // Assert accounts is not empty
    Assert.isTrue(accounts.iterator().hasNext());
    return StreamSupport.stream(accounts.spliterator(), false).map(this::toResource)
            .collect(Collectors.toList());
}