Example usage for java.util.stream Stream empty

List of usage examples for java.util.stream Stream empty

Introduction

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

Prototype

public static <T> Stream<T> empty() 

Source Link

Document

Returns an empty sequential Stream .

Usage

From source file:com.yahoo.bard.webservice.util.SimplifiedIntervalList.java

/**
 * Takes one or more lists of intervals, and combines them into a single, sorted list with the minimum number of
 * intervals needed to capture exactly the same instants as the original intervals.
 * <p>//from ww  w . j  av a  2 s  . co m
 * If any subintervals of the input collection abut or overlap they will be replaced with a single, combined
 * interval.
 * <p>
 * Examples:
 * <ul>
 * <li>['2014/2017', '2015/2020'] will combine into ['2014/2020']
 * <li>['2015/2016', '2016/2017'] will combine into ['2015/2017]
 * <li>['2015/2016', '2013/2014'] will sort into ['2013/2014', '2015/2016']
 * <li>['2015/2015', '2015/2016', '2012/2013'] will sort and combine to ['2012/2013', '2015/2016']
 * </ul>
 * @param intervals  The collection(s) of intervals being collated
 *
 * @return A single list of sorted intervals simplified to the smallest number of intervals able to describe the
 * duration
 */
@SafeVarargs
public static SimplifiedIntervalList simplifyIntervals(Collection<Interval>... intervals) {
    Stream<Interval> allIntervals = Stream.empty();
    for (Collection<Interval> intervalCollection : intervals) {
        allIntervals = Stream.concat(allIntervals, intervalCollection.stream());
    }

    return allIntervals.sorted(IntervalStartComparator.INSTANCE::compare).collect(getCollector());
}

From source file:com.github.pjungermann.config.specification.DefaultConfigSpecificationLoaderTest.java

@Test
public void load_nonRecursiveAndEmptyStream_emptySpecification() {
    ConfigSpecification specification = loader.load(false, Stream.empty());

    assertSame(converter, specification.typeConverter);
    assertTrue(specification.constraints.isEmpty());
    assertTrue(specification.errors.isEmpty());
}

From source file:com.ggvaidya.scinames.ui.DatasetImporterController.java

public Stream<Dataset> getImportedDatasets() {
    if (currentDataset == null)
        return Stream.empty();

    return Stream.of(currentDataset);
}

From source file:org.trustedanalytics.cloud.cc.api.customizations.FeignErrorDecoderHandler.java

private Stream<String> decodeExpectedFields(Response response) {
    String body = EMPTY_STRING;/*from w  w  w  .jav a2s .  c  om*/
    try {
        body = IOUtils.toString(response.body().asInputStream(), Charsets.UTF_8.toString());
        JsonNode json = MAPPER.readValue(body, JsonNode.class);
        return fieldPaths.stream().map(json::path).filter(JsonNode::isValueNode).map(JsonNode::asText);
    } catch (Exception e) {
        LOGGER.info("Unable to deserialize response: {}", body);
        return Stream.empty();
    }
}

From source file:org.zaproxy.VerifyScripts.java

private static Stream<Arguments> scriptsRuby() {
    if (!SystemUtils.IS_JAVA_1_8) {
        // Ref: https://github.com/zaproxy/zaproxy/issues/3944
        return Stream.empty();
    }//  w ww  .  j  ava  2  s  . com
    return testData(".rb", (Compilable) new JRubyEngineFactory().getScriptEngine());
}

From source file:com.github.pjungermann.config.specification.DefaultConfigSpecificationLoaderTest.java

@Test
public void load_recursiveAndEmptyStream_emptySpecification() {
    ConfigSpecification specification = loader.load(true, Stream.empty());

    assertSame(converter, specification.typeConverter);
    assertTrue(specification.constraints.isEmpty());
    assertTrue(specification.errors.isEmpty());
}

From source file:acmi.l2.clientmod.l2resources.Environment.java

public Stream<File> listFiles() {
    return paths.stream().flatMap(s -> {
        File file = new File(startDir, s);
        File parent = file.getParentFile();
        if (!parent.exists())
            return Stream.empty();
        return FileUtils.listFiles(file.getParentFile(), new WildcardFileFilter(file.getName()), null).stream();
    });/*  w  w w  .  j  a  va2s  .  c  om*/
}

From source file:org.zaproxy.VerifyScripts.java

private static Stream<Arguments> scriptsZest() {
    // Just collect the files for now (Issue 114).
    getFilesWithExtension(".zst");
    return Stream.empty();
}

From source file:org.apache.james.webadmin.service.MailRepositoryStoreServiceTest.java

@Test
public void listMailRepositoriesShouldReturnEmptyWhenEmpty() {
    when(mailRepositoryStore.getPaths()).thenReturn(Stream.empty());

    assertThat(testee.listMailRepositories()).isEmpty();
}

From source file:com.spotify.heroic.shell.task.DeleteKeys.java

@Override
public AsyncFuture<Void> run(final ShellIO io, final TaskParameters base) throws Exception {
    final Parameters params = (Parameters) base;

    final MetricBackendGroup group = metrics.useOptionalGroup(params.group);

    final QueryOptions options = QueryOptions.builder().tracing(Tracing.fromBoolean(params.tracing)).build();

    Stream<BackendKey> keys = Stream.empty();

    keys = Stream.concat(keys, Tasks.parseJsonLines(mapper, params.file, io, BackendKeyArgument.class)
            .map(BackendKeyArgument::toBackendKey));

    final ImmutableList.Builder<BackendKey> arguments = ImmutableList.builder();

    for (final String k : params.keys) {
        arguments.add(mapper.readValue(k, BackendKeyArgument.class).toBackendKey());
    }//  ww  w . j  a v  a  2s .  c  om

    keys = Stream.concat(keys, arguments.build().stream());

    if (!params.ok) {
        return askForOk(io, keys);
    }

    return doDelete(io, params, group, options, keys);
}