本文整理汇总了Java中java.util.Spliterator.NONNULL属性的典型用法代码示例。如果您正苦于以下问题:Java Spliterator.NONNULL属性的具体用法?Java Spliterator.NONNULL怎么用?Java Spliterator.NONNULL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.Spliterator
的用法示例。
在下文中一共展示了Spliterator.NONNULL属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: concat
/**
* Returns a {@link Stream} containing the elements of the first stream, followed by the elements
* of the second stream, and so on.
*
* <p>This is equivalent to {@code Stream.of(streams).flatMap(stream -> stream)}, but the returned
* stream may perform better.
*
* @see Stream#concat(Stream, Stream)
*/
@SafeVarargs
public static <T> Stream<T> concat(Stream<? extends T>... streams) {
// TODO(lowasser): consider an implementation that can support SUBSIZED
boolean isParallel = false;
int characteristics = Spliterator.ORDERED | Spliterator.SIZED | Spliterator.NONNULL;
long estimatedSize = 0L;
ImmutableList.Builder<Spliterator<? extends T>> splitrsBuilder =
new ImmutableList.Builder<>(streams.length);
for (Stream<? extends T> stream : streams) {
isParallel |= stream.isParallel();
Spliterator<? extends T> splitr = stream.spliterator();
splitrsBuilder.add(splitr);
characteristics &= splitr.characteristics();
estimatedSize = LongMath.saturatedAdd(estimatedSize, splitr.estimateSize());
}
return StreamSupport.stream(
CollectSpliterators.flatMap(
splitrsBuilder.build().spliterator(),
splitr -> (Spliterator<T>) splitr,
characteristics,
estimatedSize),
isParallel);
}
示例2: characteristics
public int characteristics() {
return Spliterator.DISTINCT | Spliterator.CONCURRENT |
Spliterator.NONNULL;
}
示例3: characteristics
public int characteristics() {
return Spliterator.CONCURRENT | Spliterator.NONNULL;
}
示例4: characteristics
public int characteristics() {
return (Spliterator.ORDERED |
Spliterator.NONNULL |
Spliterator.CONCURRENT);
}
示例5: characteristics
public int characteristics() {
return Spliterator.DISTINCT | Spliterator.SORTED |
Spliterator.ORDERED | Spliterator.CONCURRENT |
Spliterator.NONNULL;
}
示例6: characteristics
@Override
public int characteristics() {
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.IMMUTABLE | Spliterator.NONNULL |
Spliterator.DISTINCT | Spliterator.SORTED;
}
示例7: characteristics
public int characteristics() {
return (Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.NONNULL | Spliterator.IMMUTABLE);
}
示例8: characteristics
public int characteristics() {
return Spliterator.ORDERED | Spliterator.NONNULL |
Spliterator.CONCURRENT;
}
示例9: resources
/**
* Returns a stream whose elements are the URLs of all the resources with
* the given name. A resource is some data (images, audio, text, etc) that
* can be accessed by class code in a way that is independent of the
* location of the code.
*
* <p> The name of a resource is a {@code /}-separated path name that
* identifies the resource.
*
* <p> The resources will be located when the returned stream is evaluated.
* If the evaluation results in an {@code IOException} then the I/O
* exception is wrapped in an {@link UncheckedIOException} that is then
* thrown.
*
* <p> Resources in named modules are subject to the encapsulation rules
* specified by {@link Module#getResourceAsStream Module.getResourceAsStream}.
* Additionally, and except for the special case where the resource has a
* name ending with "{@code .class}", this method will only find resources in
* packages of named modules when the package is {@link Module#isOpen(String)
* opened} unconditionally (even if the caller of this method is in the
* same module as the resource). </p>
*
* @implSpec The default implementation invokes {@link #getResources(String)
* getResources} to find all the resources with the given name and returns
* a stream with the elements in the enumeration as the source.
*
* @apiNote When overriding this method it is recommended that an
* implementation ensures that any delegation is consistent with the {@link
* #getResource(java.lang.String) getResource(String)} method. This should
* ensure that the first element returned by the stream is the same
* resource that the {@code getResource(String)} method would return.
*
* @param name
* The resource name
*
* @return A stream of resource {@link java.net.URL URL} objects. If no
* resources could be found, the stream will be empty. Resources
* for which a {@code URL} cannot be constructed, are in a package
* that is not opened unconditionally, or access to the resource
* is denied by the security manager, will not be in the stream.
*
* @throws NullPointerException If {@code name} is {@code null}
*
* @since 9
*/
public Stream<URL> resources(String name) {
Objects.requireNonNull(name);
int characteristics = Spliterator.NONNULL | Spliterator.IMMUTABLE;
Supplier<Spliterator<URL>> si = () -> {
try {
return Spliterators.spliteratorUnknownSize(
getResources(name).asIterator(), characteristics);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
};
return StreamSupport.stream(si, characteristics, false);
}