本文整理匯總了Java中java.util.stream.Stream.empty方法的典型用法代碼示例。如果您正苦於以下問題:Java Stream.empty方法的具體用法?Java Stream.empty怎麽用?Java Stream.empty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.stream.Stream
的用法示例。
在下文中一共展示了Stream.empty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolveCompletions
import java.util.stream.Stream; //導入方法依賴的package包/類
@Override
public Stream<LookupElementBuilder> resolveCompletions(String propertyName, PsiType psiType) {
PsiType[] parameters = ((PsiClassReferenceType) psiType).getParameters();
Stream<PsiClass> psiClassStream = null;
if (parameters.length == 1 && parameters[0] instanceof PsiWildcardType) {
PsiWildcardType psiWildcardType = ((PsiWildcardType) parameters[0]);
if (psiWildcardType.isBounded()) {
if (psiWildcardType.isExtends()) {
psiClassStream = subClasses((PsiClassType) psiWildcardType.getExtendsBound()).stream();
} else if (psiWildcardType.isSuper()) {
psiClassStream = superClasses((PsiClassType) psiWildcardType.getSuperBound()).stream();
}
}
}
if (psiClassStream != null) {
return psiClassStream.map(this::buildClassLookup).filter(Optional::isPresent).map(Optional::get);
} else {
return Stream.empty();
}
}
示例2: should_collect_flatmap_an_empty_stream_into_an_empty_stream
import java.util.stream.Stream; //導入方法依賴的package包/類
@Test
public void should_collect_flatmap_an_empty_stream_into_an_empty_stream() {
// Given
Stream<String> strings = Stream.empty();
Function<String, Stream<Character>> flatMapper = string -> string.chars().mapToObj(letter -> (char)letter);
Collector<String, ?, Stream<Character>> streamCollector = CollectorsUtils.flatMapping(flatMapper);
// When
List<Character> characters = strings.collect(streamCollector).collect(toList());
// Then
assertThat(characters).isEmpty();
}
示例3: css
import java.util.stream.Stream; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public <T extends Node> Stream<RNode<T>> css(String selector) {
if (scene.getRoot() != null) {
return scene.getRoot().lookupAll(selector).stream().map(v -> new RNodeImpl<>((T) v, this));
}
return Stream.empty();
}
示例4: polygonsFrom
import java.util.stream.Stream; //導入方法依賴的package包/類
public static Stream<Polygon> polygonsFrom(Geometry g) {
if (g instanceof Polygon) {
return Stream.of((Polygon) g);
}
else if (g instanceof MultiPolygon) {
Builder<Polygon> builder = Stream.builder();
for (int i = 0; i < g.getNumGeometries(); i++) {
builder.add((Polygon) g.getGeometryN(i));
}
return builder.build();
}
return Stream.empty();
}
示例5: fileStream
import java.util.stream.Stream; //導入方法依賴的package包/類
/**
* Create a stream of files from a directory.
*
* @param dir The {@code File} that hopefully is a directory.
* @return A stream of {@code File}s.
*/
public static Stream<File> fileStream(File dir) {
File[] files;
return (dir == null || !dir.isDirectory()
|| (files = dir.listFiles()) == null)
? Stream.<File>empty()
: Arrays.stream(files);
}
示例6: backingFiles
import java.util.stream.Stream; //導入方法依賴的package包/類
private Stream<S3PropertiesFile> backingFiles() {
if (s3 == null) {
return Stream.empty();
} else {
Stream<S3PropertiesFile> stream = s3.listObjects(bucket, nodeAccess.getId()).getObjectSummaries().stream()
.filter(summary -> summary.getKey().endsWith(METRICS_EXTENSION))
.map(summary -> new S3PropertiesFile(s3, bucket, summary.getKey()));
return stream;
}
}
示例7: select
import java.util.stream.Stream; //導入方法依賴的package包/類
public static Stream<Activation> select(INeuron.ThreadState th, INeuron n, Integer rid, Range r, Range.Relation rr, InterprNode o, InterprNode.Relation or) {
Stream<Activation> results;
int s = th.activations.size();
Node node = n.node.get();
if(s == 0) return Stream.empty();
else if(s == 1) {
results = th.activations
.values()
.stream();
} else if(rid != null) {
Key bk = new Key(node, Range.MIN, rid, InterprNode.MIN);
Key ek = new Key(node, Range.MAX, rid, InterprNode.MAX);
if(th.activationsRid != null) {
results = th.activationsRid.subMap(bk, true, ek, true)
.values()
.stream();
} else return Stream.empty();
} else {
if(rr == null) {
results = th.activations.values()
.stream();
} else {
return getActivationsByRange(th, n, rid, r, rr, o, or);
}
}
return results.filter(act -> act.filter(node, rid, r, rr, o, or));
}
示例8: concat
import java.util.stream.Stream; //導入方法依賴的package包/類
/**
* Concatenate streams.
*
* @param <T> Generic type of {@link Stream}
* @param s0 The first {@code Stream}.
* @param streams The {@code Stream}s to concatenate (nulls ignored).
* @return The concatenated stream.
*/
@SafeVarargs
public static <T> Stream<T> concat(Stream<T> s0, Stream<T>... streams) {
Stream<T>[] sts = streams;
Stream<T> ret = (s0 == null) ? Stream.empty() : s0;
for (int i = 0; i < sts.length; i++) {
if (sts[i] != null) ret = Stream.concat(ret, sts[i]);
}
return ret;
}
示例9: traverseFields
import java.util.stream.Stream; //導入方法依賴的package包/類
/**
* Returns a stream of all the member fields for the specified class,
* including inherited fields from any ancestors. This includes public,
* private, protected and package private fields.
*
* @param clazz the class to traverse
* @return stream of fields
*/
public static Stream<Field> traverseFields(Class<?> clazz) {
final Class<?> parent = clazz.getSuperclass();
final Stream<Field> inherited;
if (parent != null) {
inherited = traverseFields(parent);
} else {
inherited = Stream.empty();
}
return Stream.concat(inherited, Stream.of(clazz.getDeclaredFields()));
}
示例10: createExecutionInterceptorsFromResources
import java.util.stream.Stream; //導入方法依賴的package包/類
private Stream<ExecutionInterceptor> createExecutionInterceptorsFromResources(Enumeration<URL> resources) {
if (resources == null) {
return Stream.empty();
}
return Collections.list(resources).stream().flatMap(this::createExecutionInterceptorFromResource);
}
示例11: list
import java.util.stream.Stream; //導入方法依賴的package包/類
@Override
public Stream<String> list() {
return Stream.empty();
}
示例12: getScopes
import java.util.stream.Stream; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public final Stream<Scope> getScopes() {
return (this.scopes == null) ? Stream.<Scope>empty()
: this.scopes.stream();
}
示例13: firstThrowsIfEmptyConfig
import java.util.stream.Stream; //導入方法依賴的package包/類
@Test (expected = NoSuchElementException.class)
public void firstThrowsIfEmptyConfig() {
configValues = Stream.empty();
this.first();
}
示例14: getScopes
import java.util.stream.Stream; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public final Stream<Scope> getScopes() {
return (this.scopes == null) ? Stream.<Scope>empty()
: getScopeList().stream();
}
示例15: conditional
import java.util.stream.Stream; //導入方法依賴的package包/類
public static <T> Stream<T> conditional(boolean condition, Stream<T> stream) {
return condition ? stream : Stream.empty();
}