Example usage for java.lang Iterable spliterator

List of usage examples for java.lang Iterable spliterator

Introduction

In this page you can find the example usage for java.lang Iterable spliterator.

Prototype

default Spliterator<T> spliterator() 

Source Link

Document

Creates a Spliterator over the elements described by this Iterable .

Usage

From source file:org.onosproject.p4runtime.ctl.P4RuntimeClientImpl.java

private Collection<PiMeterCellConfig> doReadMeterEntities(Collection<Entity> entitiesToRead,
        PiPipeconf pipeconf) {//from  w w  w.  j a  va 2s.com

    if (entitiesToRead.size() == 0) {
        return Collections.emptyList();
    }

    final ReadRequest request = ReadRequest.newBuilder().setDeviceId(p4DeviceId).addAllEntities(entitiesToRead)
            .build();

    final Iterable<ReadResponse> responses;
    try {
        responses = () -> blockingStub.read(request);
    } catch (StatusRuntimeException e) {
        log.warn("Unable to read meter cells: {}", e.getMessage());
        log.debug("exception", e);
        return Collections.emptyList();
    }

    List<Entity> responseEntities = StreamSupport.stream(responses.spliterator(), false)
            .map(ReadResponse::getEntitiesList).flatMap(List::stream).collect(Collectors.toList());

    return MeterEntryCodec.decodeMeterEntities(responseEntities, pipeconf);
}

From source file:org.sonar.plugins.github.PullRequestIssuePostJob.java

private Map<InputFile, Map<Integer, StringBuilder>> processIssues(GlobalReport report,
        Iterable<PostJobIssue> issues) {
    Map<InputFile, Map<Integer, StringBuilder>> commentToBeAddedByFileAndByLine = new HashMap<>();

    StreamSupport.stream(issues.spliterator(), false).filter(PostJobIssue::isNew)
            // SONARGITUB-13 Ignore issues on files not modified by the P/R
            .filter(i -> {/*from w ww  .ja v  a 2 s  .c  om*/
                InputComponent inputComponent = i.inputComponent();
                return inputComponent == null || !inputComponent.isFile()
                        || pullRequestFacade.hasFile((InputFile) inputComponent);
            }).sorted(ISSUE_COMPARATOR).forEach(i -> processIssue(report, commentToBeAddedByFileAndByLine, i));
    return commentToBeAddedByFileAndByLine;

}

From source file:org.springframework.cloud.gcp.data.spanner.core.SpannerTemplate.java

@Override
public void deleteAll(Iterable objects) {
    applyDeleteMutations(objects, (List<Mutation>) StreamSupport.stream(objects.spliterator(), false)
            .map(this.mutationFactory::delete).collect(Collectors.toList()));
}

From source file:org.springframework.cloud.gcp.data.spanner.core.SpannerTemplate.java

private List<Mutation> getMutationsForMultipleObjects(Iterable it,
        Function<Object, Collection<Mutation>> individualEntityMutationFunc) {
    return (List<Mutation>) StreamSupport.stream(it.spliterator(), false)
            .flatMap((x) -> individualEntityMutationFunc.apply(x).stream()).collect(Collectors.toList());
}

From source file:org.springframework.data.gemfire.config.annotation.support.GemFireComponentClassTypeScanner.java

/**
 * Factory method to construct an instance of the {@link GemFireComponentClassTypeScanner} initialized with
 * the given {@link Iterable} of base packages to scan.
 *
 * @param basePackages {@link Iterable} of base packages to scan for GemFire components.
 * @throws IllegalArgumentException if the {@link Iterable} of base packages is {@literal null} or empty.
 * @return an initialized instance of {@link GemFireComponentClassTypeScanner}.
 * @see #GemFireComponentClassTypeScanner(Set)
 *///from w  w w .j  ava2 s . c  om
public static GemFireComponentClassTypeScanner from(Iterable<String> basePackages) {
    return new GemFireComponentClassTypeScanner(
            stream(basePackages.spliterator(), false).collect(Collectors.toSet()));
}