Tabnine Logo
Stream.sorted
Code IndexAdd Tabnine to your IDE (free)

How to use
sorted
method
in
java.util.stream.Stream

Best Java code snippets using java.util.stream.Stream.sorted (Showing top 20 results out of 16,371)

Refine searchRefine arrow

  • Collectors.toList
  • Stream.collect
  • Stream.map
  • List.stream
  • Stream.filter
  • Set.stream
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: GoogleContainerTools/jib

 /**
  * Walks {@link #rootDir}.
  *
  * @return the walked files.
  * @throws IOException if walking the files fails.
  */
 public ImmutableList<Path> walk() throws IOException {
  try (Stream<Path> fileStream = Files.walk(rootDir)) {
   return fileStream.filter(pathFilter).sorted().collect(ImmutableList.toImmutableList());
  }
 }
}
origin: lets-blade/blade

public <T> void fireEvent(EventType type, Event event) {
  listenerMap.get(type).stream()
      .sorted(comparator)
      .forEach(listener -> listener.trigger(event));
}
origin: Graylog2/graylog2-server

public MessageProcessorsConfig withProcessors(final Set<String> availableProcessors) {
  final List<String> newOrder = new ArrayList<>();
  // Check if processor actually exists.
  processorOrder().stream()
      .filter(availableProcessors::contains)
      .forEach(newOrder::add);
  // Add availableProcessors which are not in the config yet to the end.
  availableProcessors.stream()
      .filter(processor -> !newOrder.contains(processor))
      .sorted(String.CASE_INSENSITIVE_ORDER)
      .forEach(newOrder::add);
  return toBuilder().processorOrder(newOrder).build();
}
origin: SonarSource/sonarqube

private static List<Map.Entry<String, MetricStatsInt>> fiveBiggest(DistributedMetricStatsInt distributedMetricStatsInt, ToIntFunction<MetricStatsInt> biggerCriteria) {
 Comparator<Map.Entry<String, MetricStatsInt>> comparator = Comparator.comparingInt(a -> biggerCriteria.applyAsInt(a.getValue()));
 return distributedMetricStatsInt.getForLabels()
  .entrySet()
  .stream()
  .sorted(comparator.reversed())
  .limit(5)
  .collect(MoreCollectors.toList(5));
}
origin: neo4j/neo4j

@Admin
@Description( "List the currently active config of Neo4j." )
@Procedure( name = "dbms.listConfig", mode = DBMS )
public Stream<ConfigResult> listConfig( @Name( value = "searchString", defaultValue = "" ) String searchString )
{
  Config config = graph.getDependencyResolver().resolveDependency( Config.class );
  String lowerCasedSearchString = searchString.toLowerCase();
  return config.getConfigValues().values().stream()
      .filter( c -> !c.internal() )
      .filter( c -> c.name().toLowerCase().contains( lowerCasedSearchString ) )
      .map( ConfigResult::new )
      .sorted( Comparator.comparing( c -> c.name ) );
}
origin: neo4j/neo4j

@Description( "List all constraints in the database." )
@Procedure( name = "db.constraints", mode = READ )
public Stream<ConstraintResult> listConstraints()
{
  SchemaRead schemaRead = tx.schemaRead();
  TokenNameLookup tokens = new SilentTokenNameLookup( tx.tokenRead() );
  return asList( schemaRead.constraintsGetAll() )
      .stream()
      .map( constraint -> constraint.prettyPrint( tokens ) )
      .sorted()
      .map( ConstraintResult::new );
}
origin: neo4j/neo4j

@Description( "List all procedures in the DBMS." )
@Procedure( name = "dbms.procedures", mode = DBMS )
public Stream<ProcedureResult> listProcedures()
{
  securityContext.assertCredentialsNotExpired();
  return graph.getDependencyResolver().resolveDependency( Procedures.class ).getAllProcedures().stream()
      .sorted( Comparator.comparing( a -> a.name().toString() ) )
      .map( ProcedureResult::new );
}
origin: jenkinsci/jenkins

@SuppressFBWarnings("NP_NONNULL_RETURN_VIOLATION")
public synchronized @Nonnull Collection<HashedToken> getTokenListSortedByName() {
  return tokenList.stream()
      .sorted(SORT_BY_LOWERCASED_NAME)
      .collect(Collectors.toList());
}

origin: Graylog2/graylog2-server

public AuthenticationConfig withRealms(final Set<String> availableRealms) {
  final List<String> newOrder = new ArrayList<>();
  // Check if realm actually exists.
  realmOrder().stream()
      .filter(availableRealms::contains)
      .forEach(newOrder::add);
  // Add availableRealms which are not in the config yet to the end.
  availableRealms.stream()
      .filter(realm -> !newOrder.contains(realm))
      .sorted(String.CASE_INSENSITIVE_ORDER)
      .forEach(newOrder::add);
  return toBuilder().realmOrder(newOrder).build();
}
origin: prestodb/presto

  @GuardedBy("this")
  private String getAdditionalFailureInfo(long allocated, long delta)
  {
    Map<String, Long> queryAllocations = memoryPool.getTaggedMemoryAllocations().get(queryId);

    String additionalInfo = format("Allocated: %s, Delta: %s", succinctBytes(allocated), succinctBytes(delta));

    // It's possible that a query tries allocating more than the available memory
    // failing immediately before any allocation of that query is tagged
    if (queryAllocations == null) {
      return additionalInfo;
    }

    String topConsumers = queryAllocations.entrySet().stream()
        .sorted(comparingByValue(Comparator.reverseOrder()))
        .limit(3)
        .collect(toImmutableMap(Entry::getKey, e -> succinctBytes(e.getValue())))
        .toString();

    return format("%s, Top Consumers: %s", additionalInfo, topConsumers);
  }
}
origin: SonarSource/sonarqube

private List<String> difference(Collection<String> expected, Collection<String> actual) {
 Set<String> actualSet = new HashSet<>(actual);
 return expected.stream()
  .filter(value -> !actualSet.contains(value))
  .sorted(String::compareTo)
  .collect(toList());
}
origin: neo4j/neo4j

@Description( "List all user functions in the DBMS." )
@Procedure( name = "dbms.functions", mode = DBMS )
public Stream<FunctionResult> listFunctions()
{
  securityContext.assertCredentialsNotExpired();
  return graph.getDependencyResolver().resolveDependency( Procedures.class ).getAllFunctions().stream()
      .sorted( Comparator.comparing( a -> a.name().toString() ) )
      .map( FunctionResult::new );
}
origin: lets-blade/blade

public <T> void fireEvent(EventType type, Event event) {
  listenerMap.get(type).stream()
      .sorted(comparator)
      .forEach(listener -> listener.trigger(event));
}
origin: spring-projects/spring-framework

@Nullable
private String getContentCodingKey(HttpServletRequest request) {
  String header = request.getHeader(HttpHeaders.ACCEPT_ENCODING);
  if (!StringUtils.hasText(header)) {
    return null;
  }
  return Arrays.stream(StringUtils.tokenizeToStringArray(header, ","))
      .map(token -> {
        int index = token.indexOf(';');
        return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase();
      })
      .filter(this.contentCodings::contains)
      .sorted()
      .collect(Collectors.joining(","));
}
origin: prestodb/presto

  @GuardedBy("this")
  private String getAdditionalFailureInfo(long allocated, long delta)
  {
    Map<String, Long> queryAllocations = memoryPool.getTaggedMemoryAllocations().get(queryId);

    String additionalInfo = format("Allocated: %s, Delta: %s", succinctBytes(allocated), succinctBytes(delta));

    // It's possible that a query tries allocating more than the available memory
    // failing immediately before any allocation of that query is tagged
    if (queryAllocations == null) {
      return additionalInfo;
    }

    String topConsumers = queryAllocations.entrySet().stream()
        .sorted(comparingByValue(Comparator.reverseOrder()))
        .limit(3)
        .collect(toImmutableMap(Entry::getKey, e -> succinctBytes(e.getValue())))
        .toString();

    return format("%s, Top Consumers: %s", additionalInfo, topConsumers);
  }
}
origin: apache/flink

  private Optional<Event> verifyWindowContiguity(List<Event> newValues, Collector<String> out) {
    return newValues.stream()
      .sorted(Comparator.comparingLong(Event::getSequenceNumber))
      .reduce((event, event2) -> {
        if (event2.getSequenceNumber() - 1 != event.getSequenceNumber()) {
          out.collect("Alert: events in window out ouf order!");
        }

        return event2;
      });
  }
}
origin: org.springframework/spring-webmvc

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

@Nullable
private String getContentCodingKey(ServerWebExchange exchange) {
  String header = exchange.getRequest().getHeaders().getFirst("Accept-Encoding");
  if (!StringUtils.hasText(header)) {
    return null;
  }
  return Arrays.stream(StringUtils.tokenizeToStringArray(header, ","))
      .map(token -> {
        int index = token.indexOf(';');
        return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase();
      })
      .filter(this.contentCodings::contains)
      .sorted()
      .collect(Collectors.joining(","));
}
origin: Graylog2/graylog2-server

public List<SearchResponseDecorator> searchResponseDecoratorsForStream(String streamId) {
  return this.decoratorService.findForStream(streamId)
    .stream()
    .sorted()
    .map(this::instantiateSearchResponseDecorator)
    .filter(Objects::nonNull)
    .collect(Collectors.toList());
}
java.util.streamStreamsorted

Javadoc

Returns a stream consisting of the elements of this stream, sorted according to natural order. If the elements of this stream are not Comparable, a java.lang.ClassCastException may be thrown when the terminal operation is executed.

For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

This is a stateful intermediate operation.

Popular methods of Stream

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

Popular in Java

  • Finding current android device location
  • startActivity (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Notification (javax.management)
  • Top plugins for Android Studio
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