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:org.mskcc.shenkers.data.interval.GIntervalTree.java

public Stream<Node> 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.polymap.rhei.batik.PanelPath.java

public Stream<PanelIdentifier> stream() {
    return StreamSupport.stream(spliterator(), false);
}

From source file:net.dv8tion.jda.bot.utils.cache.impl.ShardCacheViewImpl.java

@Override
public Stream<JDA> stream() {
    return StreamSupport.stream(spliterator(), false);
}

From source file:gov.gtas.controller.CaseDispositionController.java

@RequestMapping(method = RequestMethod.GET, value = "/getRuleCats")
public List<RuleCat> getRuleCats() throws Exception {

    List<RuleCat> _tempRuleCatList = new ArrayList<RuleCat>();
    Iterable<RuleCat> _tempIterable = ruleCatService.findAll();
    if (_tempIterable != null) {
        _tempRuleCatList = StreamSupport.stream(_tempIterable.spliterator(), false)
                .collect(Collectors.toList());
    }/*  w ww  .ja va2s  .  co  m*/
    for (RuleCat _tempRuleCat : _tempRuleCatList) {
        //_tempRuleCat.setHitsDispositions(null);
    }
    return _tempRuleCatList;
}

From source file:net.dv8tion.jda.core.utils.cache.impl.AbstractCacheView.java

@Override
public Stream<T> stream() {
    return StreamSupport.stream(spliterator(), false);
}

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

@Override
public Relationship buildRelation(Node parent, Node child, DocumentRelationContext context) {
    String relationName = buildRelationName(parent, child, context);

    RelationshipType type = RelationshipType.withName(relationName);

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

    Relationship relationship;/*from ww w .j ava  2  s  .  co  m*/

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

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

    //manage array of keys

    String[] keys = new String[0];

    //create property if doesn't exists (new relation)
    if (relationship.getAllProperties().containsKey(DOC_KEYS)) {
        keys = (String[]) relationship.getProperty(DOC_KEYS);
    }

    //set document key into property
    String documentKey = context.getDocumentKey();
    if (!ArrayUtils.contains(keys, documentKey)) {
        keys = ArrayUtils.add(keys, documentKey);
        relationship.setProperty(DOC_KEYS, keys);
    }

    return relationship;
}

From source file:org.sonar.plugins.css.embedded.EmbeddedCssAnalyzerSensor.java

@Override
public List<InputFile> filesToAnalyze(FileSystem fileSystem) {
    return StreamSupport.stream(fileSystem.inputFiles(mainFilePredicate(fileSystem)).spliterator(), false)
            .collect(Collectors.toList());
}

From source file:net.dv8tion.jda.bot.utils.cache.impl.ShardCacheViewImpl.java

@Override
public Stream<JDA> parallelStream() {
    return StreamSupport.stream(spliterator(), true);
}

From source file:io.syndesis.dao.DeploymentDescriptorTest.java

@Test
@SuppressWarnings({ "PMD.JUnitTestsShouldIncludeAssert", "PMD.JUnitTestContainsTooManyAsserts" })
public void deploymentDescriptorTakeCueFromConnectorDescriptor() {
    for (final JsonNode entry : deployment) {
        if ("connector".equals(entry.get("kind").asText())) {

            final String connectorId = entry.get("data").get("id").asText();

            final JsonNode connectorData = entry.get("data");
            final JsonNode connectorPropertiesJson = connectorData.get("properties");

            final JsonNode actions = connectorData.get("actions");
            StreamSupport.stream(actions.spliterator(), true).forEach(action -> {
                final String actionName = action.get("name").asText();
                final String gav = action.get("camelConnectorGAV").asText();

                assertThat(gav).as("Action `%s` does not have `camelConnectorGAV` property", actionName)
                        .isNotEmpty();//from  w w w. j a  va2s  .com

                final String[] coordinates = gav.split(":");

                final Set<String> names = mavenArtifactProvider.addArtifactToCatalog(camelCatalog,
                        connectorCatalog, coordinates[0], coordinates[1], coordinates[2]);
                assertThat(names).as("Could not resolve artifact for Camel catalog with GAV: %s:%s:%s",
                        (Object[]) coordinates).isNotEmpty();

                final String scheme = action.get("camelConnectorPrefix").asText();

                try {
                    camelCatalog.asEndpointUri(scheme, new HashMap<>(), false);
                } catch (final URISyntaxException e) {
                    fail("Action `%s` cannot be added to Camel context", actionName, e);
                }

                final String componentJsonSchemaFromCatalog = camelCatalog.componentJSonSchema(scheme);
                final JsonNode catalogedJsonSchema;
                try {
                    catalogedJsonSchema = MAPPER.readTree(componentJsonSchemaFromCatalog);
                } catch (final IOException e) {
                    fail("Unable to parse Camel component JSON schema", e);
                    return;// never happens
                }

                final JsonNode component = catalogedJsonSchema.get("component");
                final String groupId = component.get("groupId").asText();
                final String artifactId = component.get("artifactId").asText();
                final String version = component.get("version").asText();

                assertThat(new String[] { groupId, artifactId, version })
                        .as("The scheme `%s` was resolved from a unexpected artifact", scheme)
                        .isEqualTo(coordinates);

                final JsonNode componentPropertiesFromCatalog = catalogedJsonSchema.get("componentProperties");

                assertConnectorProperties(connectorId, connectorPropertiesJson, componentPropertiesFromCatalog);

                assertActionProperties(connectorId, action, actionName, catalogedJsonSchema);

                assertActionDataShapes(connectorCatalog, action, actionName, coordinates);
            });
        }
    }

}

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

@Override
public List<ScheduleDto> findAll(RouteDto routeDto, Date date) {
    List<ScheduleDto> schedules = new ArrayList<>();
    Place originPlace = placeDataService.findOne(routeDto.getOrigin().getId());
    Place destinationPlace = placeDataService.findOne(routeDto.getDestination().getId());

    if (originPlace != null && destinationPlace != null) {
        Route route = routeDataService.findByOriginAndDestination(originPlace, destinationPlace);

        if (route != null) {

            /* Get tomorrow date */
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);/*ww w .jav  a2 s  . c o m*/
            calendar.add(Calendar.DATE, 1);

            schedules.addAll(StreamSupport.stream(scheduleDataService
                    .findByRouteAndDateBetween(route, date, calendar.getTime()).spliterator(), false)
                    .map(ScheduleDto::new).collect(Collectors.toList()));
        }
    }

    return schedules;
}