Example usage for java.util Spliterator NONNULL

List of usage examples for java.util Spliterator NONNULL

Introduction

In this page you can find the example usage for java.util Spliterator NONNULL.

Prototype

int NONNULL

To view the source code for java.util Spliterator NONNULL.

Click Source Link

Document

Characteristic value signifying that the source guarantees that encountered elements will not be null .

Usage

From source file:org.codice.ddf.catalog.ui.metacard.impl.ZipSplitter.java

@Override
public Stream<StorableResource> split(StorableResource storableResource,
        Map<String, ? extends Serializable> arguments) throws IOException {
    ZipIterator zipIterator = new ZipIterator(storableResource.getInputStream());
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(zipIterator, Spliterator.NONNULL), false)
            .onClose(zipIterator::close);
}

From source file:org.dice_research.topicmodeling.io.test.AbstractCorpusIOTest.java

public void writeCorpus() {
    OutputStream out = null;//from w  w w.j  a  v a2  s. c  om
    try {
        if (writer != null) {
            out = new BufferedOutputStream(new FileOutputStream(testFile));
            writer.writeCorpus(corpus, out);
        } else if (consumer != null) {
            StreamSupport.stream(Spliterators.spliterator(corpus.iterator(), corpus.getNumberOfDocuments(),
                    Spliterator.DISTINCT & Spliterator.NONNULL), false).forEach(consumer);
        } else {
            Assert.fail("Test is misconfigured since writer==null and consumer==null.");
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Got an Exception: " + e.getLocalizedMessage());
    } finally {
        IOUtils.closeQuietly(out);
        if ((consumer != null) && (consumer instanceof Closeable)) {
            IOUtils.closeQuietly((Closeable) consumer);
        }
    }
}

From source file:org.dice_research.topicmodeling.io.test.AbstractCorpusIOTest.java

public Corpus readCorpus() {
    InputStream in = null;/*from   w ww .j  av  a2 s.  co m*/
    try {
        if (reader != null) {
            in = new BufferedInputStream(new FileInputStream(testFile));
            reader.readCorpus(in);
            return reader.getCorpus();
        } else if (supplier != null) {
            return new DocumentListCorpus<List<Document>>(StreamSupport
                    .stream(Spliterators.spliteratorUnknownSize(new DocumentSupplierAsIterator(supplier),
                            Spliterator.DISTINCT & Spliterator.NONNULL), false)
                    .collect(Collectors.toList()));
        } else {
            Assert.fail("Test is misconfigured since reader==null and supplier==null.");
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Got an Exception: " + e.getLocalizedMessage());
    } finally {
        IOUtils.closeQuietly(in);
    }
    return null;
}

From source file:org.kie.workbench.common.dmn.backend.DMNMarshallerTest.java

private static Node<View, ?> nodeOfDefinition(final Iterator<Node<View, ?>> nodesIterator, final Class aClass) {
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(nodesIterator, Spliterator.NONNULL), false)
            .filter(node -> aClass.isInstance(node.getContent().getDefinition())).findFirst().get();
}

From source file:org.nuxeo.ecm.automation.DetachTemplateFromAllDocuments.java

protected List<String> getDocumentsWithTemplate(CoreSession session, String query) {
    List<String> ids = new ArrayList<String>();
    IterableQueryResult it = null;// w w  w .j  a  va2s .  c  o  m
    try {
        it = session.queryAndFetch(query, NXQL);
        Spliterator<Map<String, Serializable>> spliterator = Spliterators.spliteratorUnknownSize(it.iterator(),
                Spliterator.NONNULL);
        ids = StreamSupport.stream(spliterator, false).map(map -> (String) map.get(ECM_UUID))
                .collect(Collectors.toList());
    } finally {
        if (it != null) {
            it.close();
        }
    }
    return ids;
}