Stream.empty
Code IndexAdd Codota to your IDE (free)

Best code snippets using java.util.stream.Stream.empty(Showing top 20 results out of 1,917)

Refine search

  • Stream.of
  • Common ways to obtain Stream
private void myMethod () {
Stream s =
  • Stream.empty()
  • List list;list.stream()
  • AI code suggestions by Codota
}
origin: iluwatar/java-design-patterns

@Override
public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) {
 Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null)
   .map(el -> (List<Map<String, Object>>) el).findAny();
 return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty();
}
origin: google/guava

public void testConcat_refStream() {
 assertThat(Streams.concat(Stream.of("a"), Stream.of("b"), Stream.empty(), Stream.of("c", "d")))
   .containsExactly("a", "b", "c", "d")
   .inOrder();
 SpliteratorTester.of(
     () ->
       Streams.concat(Stream.of("a"), Stream.of("b"), Stream.empty(), Stream.of("c", "d"))
         .spliterator())
   .expect("a", "b", "c", "d");
}
origin: google/guava

public void testConcat_refStream_closeIsPropagated() {
 AtomicInteger closeCountB = new AtomicInteger(0);
 Stream<String> streamB = Stream.of("b").onClose(closeCountB::incrementAndGet);
 Stream<String> concatenated =
   Streams.concat(Stream.of("a"), streamB, Stream.empty(), Stream.of("c", "d"));
 assertThat(concatenated).containsExactly("a", "b", "c", "d").inOrder();
 concatenated.close();
 Truth.assertThat(closeCountB.get()).isEqualTo(1);
}
origin: google/guava

public void testConcat_refStream_parallel() {
 Truth.assertThat(
     Streams.concat(Stream.of("a"), Stream.of("b"), Stream.empty(), Stream.of("c", "d"))
       .parallel()
       .toArray())
   .asList()
   .containsExactly("a", "b", "c", "d")
   .inOrder();
}
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: google/guava

public void testForEachPair_oneEmpty() {
 Streams.forEachPair(Stream.of("a"), Stream.empty(), (a, b) -> fail());
}
origin: prestodb/presto

  @Override
  public Result apply(SemiJoinNode semiJoinNode, Captures captures, Context context)
  {
    Set<Symbol> requiredFilteringSourceInputs = Streams.concat(
        Stream.of(semiJoinNode.getFilteringSourceJoinSymbol()),
        semiJoinNode.getFilteringSourceHashSymbol().map(Stream::of).orElse(Stream.empty()))
        .collect(toImmutableSet());

    return restrictOutputs(context.getIdAllocator(), semiJoinNode.getFilteringSource(), requiredFilteringSourceInputs)
        .map(newFilteringSource ->
            semiJoinNode.replaceChildren(ImmutableList.of(semiJoinNode.getSource(), newFilteringSource)))
        .map(Result::ofPlanNode)
        .orElse(Result.empty());
  }
}
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: prestodb/presto

  @Override
  protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, SemiJoinNode semiJoinNode, Set<Symbol> referencedOutputs)
  {
    if (!referencedOutputs.contains(semiJoinNode.getSemiJoinOutput())) {
      return Optional.of(semiJoinNode.getSource());
    }

    Set<Symbol> requiredSourceInputs = Streams.concat(
        referencedOutputs.stream()
            .filter(symbol -> !symbol.equals(semiJoinNode.getSemiJoinOutput())),
        Stream.of(semiJoinNode.getSourceJoinSymbol()),
        semiJoinNode.getSourceHashSymbol().map(Stream::of).orElse(Stream.empty()))
        .collect(toImmutableSet());

    return restrictOutputs(idAllocator, semiJoinNode.getSource(), requiredSourceInputs)
        .map(newSource ->
            semiJoinNode.replaceChildren(ImmutableList.of(
                newSource, semiJoinNode.getFilteringSource())));
  }
}
origin: google/guava

public void testConcat_refStream_closeIsPropagated_Stream_flatMap() {
 // Just to demonstrate behavior of Stream::flatMap in the standard library
 AtomicInteger closeCountB = new AtomicInteger(0);
 Stream<String> streamB = Stream.of("b").onClose(closeCountB::incrementAndGet);
 Stream<String> concatenated =
   Stream.<Stream<String>>of(Stream.of("a"), streamB, Stream.empty(), Stream.of("c", "d"))
     .flatMap(x -> x);
 assertThat(concatenated).containsExactly("a", "b", "c", "d").inOrder();
 concatenated.close();
 // even without close, see doc for flatMap
 Truth.assertThat(closeCountB.get()).isEqualTo(1);
}
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: thinkaurelius/titan

public Stream<M> receiveMessages(MessageScope messageScope) {
  if (messageScope instanceof MessageScope.Global) {
    M message = vertexMemory.getMessage(vertexId,messageScope);
    if (message == null) return Stream.empty();
    else return Stream.of(message);
  } else {
    final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope;
    final Traversal<Vertex, Edge> reverseIncident = FulgoraUtil.getReverseElementTraversal(localMessageScope,vertex,vertex.tx());
    final BiFunction<M,Edge,M> edgeFct = localMessageScope.getEdgeFunction();
    return IteratorUtils.stream(reverseIncident)
        .map(e -> {
          M msg = vertexMemory.getMessage(vertexMemory.getCanonicalId(((TitanEdge) e).otherVertex(vertex).longId()), localMessageScope);
          return msg == null ? null : edgeFct.apply(msg, e);
        })
        .filter(m -> m != null);
  }
}
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> 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

private Stream<CompilationMessage> validateInjectedTypes( VariableElement field )
{
  TypeMirror fieldType = field.asType();
  if ( injectsAllowedType( fieldType ) )
  {
    return Stream.empty();
  }
  if ( injectsRestrictedType( fieldType ) )
  {
    if ( ignoresWarnings )
    {
      return Stream.empty();
    }
    return Stream.of( new ContextFieldWarning( field, "@%s usage warning: found unsupported restricted type <%s> on %s.\n" +
        "The procedure will not load unless declared via the configuration option 'dbms.security.procedures.unrestricted'.\n" +
        "You can ignore this warning by passing the option -A%s to the Java compiler",
        Context.class.getName(), fieldType.toString(), fieldFullName( field ),
        IGNORE_CONTEXT_WARNINGS_OPTION ) );
  }
  return Stream.of( new ContextFieldError( field,
      "@%s usage error: found unknown type <%s> on field %s, expected one of: %s",
      Context.class.getName(), fieldType.toString(), fieldFullName( field ),
      joinTypes( SUPPORTED_TYPES ) ) );
}
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: 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: neo4j/neo4j

private Stream<CompilationMessage> validateReturnType( ExecutableElement method )
{
  String streamClassName = Stream.class.getCanonicalName();
  TypeMirror streamType = typeUtils.erasure( elementUtils.getTypeElement( streamClassName ).asType() );
  TypeMirror returnType = method.getReturnType();
  TypeMirror erasedReturnType = typeUtils.erasure( returnType );
  TypeMirror voidType = typeUtils.getNoType( TypeKind.VOID );
  if ( typeUtils.isSameType( returnType, voidType ) )
  {
    return Stream.empty();
  }
  if ( !typeUtils.isSubtype( erasedReturnType, streamType ) )
  {
    return Stream.of( new ReturnTypeError( method, "Return type of %s#%s must be %s",
        method.getEnclosingElement().getSimpleName(), method.getSimpleName(), streamClassName ) );
  }
  return recordVisitor.visit( returnType );
}
origin: neo4j/neo4j

@Override
public Stream<CompilationMessage> visitExecutable( ExecutableElement method, Void ignored )
{
  Procedure procedure = method.getAnnotation( Procedure.class );
  if ( procedure == null )
  {
    return Stream.of( new PerformsWriteMisuseError( method, "@%s usage error: missing @%s annotation on method",
        PerformsWrites.class.getSimpleName(), Procedure.class.getSimpleName() ) );
  }
  if ( procedure.mode() != Mode.DEFAULT )
  {
    return Stream.of( new PerformsWriteMisuseError( method,
        "@%s usage error: cannot use mode other than Mode.DEFAULT",
        PerformsWrites.class.getSimpleName() ) );
  }
  return Stream.empty();
}
origin: Vedenin/useful-java-links

Stream<String> streamFromValues = Stream.of("a1", "a2", "a3");
System.out.println("streamFromValues = " + streamFromValues.collect(Collectors.toList())); // print  streamFromValues = [a1, a2, a3]
System.out.println("streamFromArrays = " + streamFromArrays.collect(Collectors.toList())); // print  streamFromArrays = [a1, a2, a3]
Stream<String> streamFromArrays1 = Stream.of(array);
System.out.println("streamFromArrays1 = " + streamFromArrays1.collect(Collectors.toList())); // print  streamFromArrays = [a1, a2, a3]
Stream<String> streamEmpty = Stream.empty();
System.out.println("streamEmpty = " + streamEmpty.collect(Collectors.toList())); // print  streamEmpty = []
java.util.streamStreamempty

Popular methods of Stream

  • collect
  • map
  • filter
  • forEach
  • findFirst
  • of
  • anyMatch
  • flatMap
  • sorted
  • toArray
  • count
  • findAny
  • count,
  • findAny,
  • reduce,
  • allMatch,
  • concat,
  • distinct,
  • mapToInt,
  • iterator,
  • limit

Popular classes and methods

  • getSharedPreferences (Context)
  • setScale (BigDecimal)
    Returns a new BigDecimal instance with the specified scale. If the new scale is greater than the old
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Format (java.text)
    Format is an abstract base class for formatting locale-sensitive information such as dates, messages
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Reference (javax.naming)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)