Tabnine Logo
Collectors.toList
Code IndexAdd Tabnine to your IDE (free)

How to use
toList
method
in
java.util.stream.Collectors

Best Java code snippets using java.util.stream.Collectors.toList (Showing top 20 results out of 71,433)

Refine searchRefine arrow

  • Stream.map
  • Stream.collect
  • List.stream
  • Collection.stream
  • Stream.filter
  • Collections.unmodifiableList
canonical example by Tabnine

public List<Integer> findDivisors(int number) {
 return Stream.iterate(1, k -> ++k)
   .limit(number)
   .filter(k -> number % k == 0)
   .collect(Collectors.toList());
}
origin: spring-projects/spring-framework

/**
 * Re-create the given mime types as media types.
 * @since 5.0
 */
public static List<MediaType> asMediaTypes(List<MimeType> mimeTypes) {
  return mimeTypes.stream().map(MediaType::asMediaType).collect(Collectors.toList());
}
origin: spring-projects/spring-framework

/**
 * Get all methods in the supplied {@link Class class} and its superclasses
 * which are annotated with the supplied {@code annotationType} but
 * which are not <em>shadowed</em> by methods overridden in subclasses.
 * <p>Default methods on interfaces are also detected.
 * @param clazz the class for which to retrieve the annotated methods
 * @param annotationType the annotation type for which to search
 * @return all annotated methods in the supplied class and its superclasses
 * as well as annotated interface default methods
 */
private List<Method> getAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationType) {
  return Arrays.stream(ReflectionUtils.getUniqueDeclaredMethods(clazz))
      .filter(method -> AnnotatedElementUtils.hasAnnotation(method, annotationType))
      .collect(Collectors.toList());
}
origin: google/guava

 @Override
 List<? extends Entry<?, ?>> createAdversarialEntries(int power, CallsCounter counter) {
  List<?> keys = createAdversarialObjects(power, counter);
  List<?> values = createAdversarialObjects(power, counter);
  return Streams.zip(keys.stream(), values.stream(), Maps::immutableEntry).collect(toList());
 }
};
origin: apache/incubator-dubbo

private <T> List<Invoker<T>> filterInvoker(List<Invoker<T>> invokers, Predicate<Invoker<T>> predicate) {
  return invokers.stream()
      .filter(predicate)
      .collect(Collectors.toList());
}
origin: apache/incubator-dubbo

private <T> List<Invoker<T>> filterInvoker(List<Invoker<T>> invokers, Predicate<Invoker<T>> predicate) {
  return invokers.stream()
      .filter(predicate)
      .collect(Collectors.toList());
}
origin: spring-projects/spring-framework

/**
 * Return all registered interceptors.
 */
protected List<Object> getInterceptors() {
  return this.registrations.stream()
      .sorted(INTERCEPTOR_ORDER_COMPARATOR)
      .map(InterceptorRegistration::getInterceptor)
      .collect(Collectors.toList());
}
origin: apache/incubator-dubbo

public static List<URL> classifyUrls(List<URL> urls, Predicate<URL> predicate) {
  return urls.stream().filter(predicate).collect(Collectors.toList());
}
origin: apache/incubator-dubbo

public static List<URL> classifyUrls(List<URL> urls, Predicate<URL> predicate) {
  return urls.stream().filter(predicate).collect(Collectors.toList());
}
origin: spring-projects/spring-framework

@Nullable
private <T> T createSingleBean(Function<WebFluxConfigurer, T> factory, Class<T> beanType) {
  List<T> result = this.delegates.stream().map(factory).filter(Objects::nonNull).collect(Collectors.toList());
  if (result.isEmpty()) {
    return null;
  }
  else if (result.size() == 1) {
    return result.get(0);
  }
  else {
    throw new IllegalStateException("More than one WebFluxConfigurer implements " +
        beanType.getSimpleName() + " factory method.");
  }
}
origin: spring-projects/spring-framework

private List<SyncHandlerMethodArgumentResolver> initBinderResolvers(
    ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry reactiveRegistry,
    ConfigurableApplicationContext context) {
  return initResolvers(customResolvers, reactiveRegistry, context, false, Collections.emptyList()).stream()
      .filter(resolver -> resolver instanceof SyncHandlerMethodArgumentResolver)
      .map(resolver -> (SyncHandlerMethodArgumentResolver) resolver)
      .collect(Collectors.toList());
}
origin: spring-projects/spring-framework

@Override
public Collection<List<String>> values() {
  return this.headers.getHeaderNames().stream()
      .map(this.headers::get)
      .collect(Collectors.toList());
}
origin: spring-projects/spring-framework

private static void addBindValue(Map<String, Object> params, String key, List<?> values) {
  if (!CollectionUtils.isEmpty(values)) {
    values = values.stream()
        .map(value -> value instanceof FormFieldPart ? ((FormFieldPart) value).value() : value)
        .collect(Collectors.toList());
    params.put(key, values.size() == 1 ? values.get(0) : values);
  }
}
origin: spring-projects/spring-framework

private List<byte[]> getDelimiterBytes(@Nullable MimeType mimeType) {
  return this.delimitersCache.computeIfAbsent(getCharset(mimeType),
      charset -> this.delimiters.stream()
          .map(s -> s.getBytes(charset))
          .collect(Collectors.toList()));
}
origin: spring-projects/spring-framework

/**
 * Return the configured argument resolvers.
 */
public List<SyncHandlerMethodArgumentResolver> getResolvers() {
  return this.delegate.getResolvers().stream()
      .map(resolver -> (SyncHandlerMethodArgumentResolver) resolver)
      .collect(Collectors.toList());
}
origin: eclipse-vertx/vert.x

public synchronized List<T> handlers() {
 return handlerMap.values().stream()
  .flatMap(handlers -> handlers.list.stream())
  .map(holder -> holder.handler)
  .collect(Collectors.toList());
}
origin: spring-projects/spring-framework

private void updateFilters() {
  if (this.filters.isEmpty()) {
    return;
  }
  List<WebFilter> filtersToUse = this.filters.stream()
      .peek(filter -> {
        if (filter instanceof ForwardedHeaderTransformer && this.forwardedHeaderTransformer == null) {
          this.forwardedHeaderTransformer = (ForwardedHeaderTransformer) filter;
        }
      })
      .filter(filter -> !(filter instanceof ForwardedHeaderTransformer))
      .collect(Collectors.toList());
  this.filters.clear();
  this.filters.addAll(filtersToUse);
}
origin: spring-projects/spring-framework

/**
 * Parse the comma-separated string into a list of {@code MimeType} objects.
 * @param mimeTypes the string to parse
 * @return the list of mime types
 * @throws InvalidMimeTypeException if the string cannot be parsed
 */
public static List<MimeType> parseMimeTypes(String mimeTypes) {
  if (!StringUtils.hasLength(mimeTypes)) {
    return Collections.emptyList();
  }
  return tokenize(mimeTypes).stream()
      .map(MimeTypeUtils::parseMimeType).collect(Collectors.toList());
}
origin: apache/incubator-druid

public List<PostAggregator> getPostAggregators()
{
 return aggregations.stream()
           .map(Aggregation::getPostAggregator)
           .filter(Objects::nonNull)
           .collect(Collectors.toList());
}
origin: eclipse-vertx/vert.x

@Override
public void values(Handler<AsyncResult<List<V>>> asyncResultHandler) {
 List<V> result = map.values().stream()
  .filter(Holder::hasNotExpired)
  .map(h -> h.value)
  .collect(toList());
 asyncResultHandler.handle(Future.succeededFuture(result));
}
java.util.streamCollectorstoList

Popular methods of Collectors

  • toSet
  • joining
  • toMap
  • groupingBy
  • toCollection
  • collectingAndThen
  • counting
  • mapping
  • partitioningBy
  • reducing
  • toConcurrentMap
  • maxBy
  • toConcurrentMap,
  • maxBy,
  • summingInt,
  • summingLong,
  • groupingByConcurrent,
  • minBy,
  • summingDouble,
  • averagingInt,
  • summarizingLong

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • startActivity (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now