本文整理了Java中java.util.stream.Stream.empty()
方法的一些代码示例,展示了Stream.empty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stream.empty()
方法的具体详情如下:
包路径:java.util.stream.Stream
类名称:Stream
方法名:empty
暂无
代码示例来源:origin: neo4j/neo4j
public static <T> Stream<T> ofNullable( T obj )
{
if ( obj == null )
{
return Stream.empty();
}
else
{
return Stream.of( obj );
}
}
}
代码示例来源:origin: reactor/reactor-core
@Override
public Stream<? extends Scannable> inners() {
FilterWhenInner c = asyncFilter;
return c == null ? Stream.empty() : Stream.of(c);
}
}
代码示例来源:origin: reactor/reactor-core
@Override
public Stream<? extends Scannable> inners() {
FilterWhenInner c = current;
return c == null ? Stream.empty() : Stream.of(c);
}
}
代码示例来源:origin: reactor/reactor-core
@Override
public Stream<? extends Scannable> inners() {
UnicastProcessor<T> w = window;
return w == null ? Stream.empty() : Stream.of(w);
}
代码示例来源:origin: speedment/speedment
public static <T> Stream<T> streamOfNullable(T element) {
// Needless to say, element is nullable...
if (element == null) {
return Stream.empty();
} else {
return Stream.of(element);
}
}
代码示例来源:origin: reactor/reactor-core
@Override
public Stream<? extends Scannable> inners() {
return window == null ? Stream.empty() : Stream.of(window);
}
代码示例来源:origin: neo4j/neo4j
private Stream<CompilationMessage> validateConstructor( Element extensionClass )
{
Optional<ExecutableElement> publicNoArgConstructor =
constructorsIn( extensionClass.getEnclosedElements() ).stream()
.filter( c -> c.getModifiers().contains( Modifier.PUBLIC ) )
.filter( c -> c.getParameters().isEmpty() ).findFirst();
if ( !publicNoArgConstructor.isPresent() )
{
return Stream.of( new ExtensionMissingPublicNoArgConstructor( extensionClass,
"Extension class %s should contain a public no-arg constructor, none found.", extensionClass ) );
}
return Stream.empty();
}
}
代码示例来源:origin: neo4j/neo4j
public Stream<CompilationMessage> validateReturnType( ExecutableElement method )
{
TypeMirror returnType = method.getReturnType();
if ( !allowedTypesValidator.test( returnType ) )
{
return Stream.of( new ReturnTypeError( method,
"Unsupported return type <%s> of function defined in <%s#%s>.", returnType,
method.getEnclosingElement(), method.getSimpleName() ) );
}
return Stream.empty();
}
代码示例来源:origin: neo4j/neo4j
private Stream<CompilationMessage> validateParameters( ExecutableElement resultMethod,
Class<? extends Annotation> annotation )
{
if ( !isValidAggregationSignature( resultMethod ) )
{
return Stream.of( new AggregationError( resultMethod,
"@%s usage error: method should be public, non-static and without parameters.",
annotation.getSimpleName() ) );
}
return Stream.empty();
}
代码示例来源:origin: lettuce-io/lettuce-core
/**
* Returns a {@link Stream} wrapper for the value. The resulting stream contains either the value if a this value
* {@link #hasValue() has a value} or it is empty if the value is empty.
*
* @return {@link Stream} wrapper for the value.
*/
public Stream<V> stream() {
if (hasValue()) {
return Stream.of(value);
}
return Stream.empty();
}
}
代码示例来源:origin: speedment/speedment
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()));
}
代码示例来源:origin: neo4j/neo4j
private static Stream<CompilationMessage> validateNonContextField( VariableElement field )
{
Set<Modifier> modifiers = field.getModifiers();
if ( !modifiers.contains( Modifier.STATIC ) )
{
return Stream.of( new FieldError( field, "Field %s#%s should be static",
field.getEnclosingElement().getSimpleName(), field.getSimpleName() ) );
}
return Stream.empty();
}
代码示例来源:origin: SonarSource/sonarqube
private String guessResponseType(String path, String action) {
return guessResponseOuterClassName(path).flatMap(
potentialClassName -> guessResponseInnerClassName(action).flatMap(potentialInnerClassName -> {
try {
String guess = "org.sonarqube.ws." + potentialClassName + "$" + potentialInnerClassName;
Helper.class.forName(guess);
return Stream.of(guess.replaceFirst("\\$", "."));
} catch (ClassNotFoundException e) {
}
return Stream.empty();
})).findFirst().orElseGet(() -> {
return "String";
});
}
代码示例来源:origin: biezhi/30-seconds-of-java8
public static List<Class<?>> getAllInterfaces(final Class<?> cls) {
return Stream.concat(
Arrays.stream(cls.getInterfaces()).flatMap(intf ->
Stream.concat(Stream.of(intf), getAllInterfaces(intf).stream())),
cls.getSuperclass() == null ? Stream.empty() : getAllInterfaces(cls.getSuperclass()).stream()
).distinct().collect(Collectors.toList());
}
代码示例来源:origin: thinkaurelius/titan
@Override
public Stream<M> receiveMessages(MessageScope messageScope) {
if (messageScope instanceof MessageScope.Global) {
return super.receiveMessages(messageScope);
} else {
final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope;
M aggregateMsg = vertexMemory.getAggregateMessage(vertexId,localMessageScope);
if (aggregateMsg==null) return Stream.empty();
else return Stream.of(aggregateMsg);
}
}
代码示例来源:origin: neo4j/neo4j
public Stream<CompilationMessage> validateName( ExecutableElement method )
{
Optional<String> customName = customNameExtractor.apply( method.getAnnotation( annotationType ) );
if ( customName.isPresent() )
{
if ( isInRootNamespace( customName.get() ) )
{
return Stream.of( rootNamespaceError( method, customName.get() ) );
}
return Stream.empty();
}
PackageElement namespace = elements.getPackageOf( method );
if ( namespace == null )
{
return Stream.of( rootNamespaceError( method ) );
}
return Stream.empty();
}
代码示例来源:origin: SonarSource/sonarqube
private Stream<String> createOracleAutoIncrementStatements() {
if (!Oracle.ID.equals(dialect.getId())) {
return Stream.empty();
}
return pkColumnDefs.stream()
.filter(this::isAutoIncrement)
.flatMap(columnDef -> of(createSequenceFor(tableName), createOracleTriggerForTable(tableName)));
}
代码示例来源:origin: neo4j/neo4j
private Stream<CompilationMessage> validateModifiers( VariableElement field )
{
if ( !hasValidModifiers( field ) )
{
return Stream.of( new ContextFieldError( field,
"@%s usage error: field %s should be public, non-static and non-final", Context.class.getName(),
fieldFullName( field ) ) );
}
return Stream.empty();
}
代码示例来源:origin: neo4j/neo4j
private Stream<CompilationMessage> validateAggregationUpdateMethod( ExecutableElement aggregationFunction, Element returnType,
List<ExecutableElement> updateMethods )
{
if ( updateMethods.size() != 1 )
{
return Stream.of( missingAnnotation( aggregationFunction, returnType, updateMethods, UserAggregationUpdate.class ) );
}
Stream<CompilationMessage> errors = Stream.empty();
ExecutableElement updateMethod = updateMethods.iterator().next();
if ( !isValidUpdateSignature( updateMethod ) )
{
errors = Stream.of( new AggregationError( updateMethod,
"@%s usage error: method should be public, non-static and define 'void' as return type.",
UserAggregationUpdate.class.getSimpleName() ) );
}
return Stream.concat( errors, functionVisitor.validateParameters( updateMethod.getParameters() ) );
}
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
public Set<? extends RxWebSocketSession> getOpenSessions() {
return webSocketSessionRepository.getChannelGroup().stream().flatMap((Function<Channel, Stream<RxWebSocketSession>>) ch -> {
NettyRxWebSocketSession s = ch.attr(NettyRxWebSocketSession.WEB_SOCKET_SESSION_KEY).get();
if (s != null && s.isOpen()) {
return Stream.of(s);
}
return Stream.empty();
}).collect(Collectors.toSet());
}
内容来源于网络,如有侵权,请联系作者删除!