public static Comparator<String> severity() { return Comparator.comparingInt(STATUS_ORDER::indexOf); }
private static Comparator<MethodTree> comparingPositions() { return comparingInt(InconsistentOverloads::getStartPosition); }
private static Comparator<MethodTree> comparingArity() { return comparingInt(ParameterTrie::getMethodTreeArity); }
public void finish() { list.sort(Comparator.comparingInt(ResourceEntry::getId)); }
private static List<MethodNode> sortMethodsByLine(List<MethodNode> methods) { List<MethodNode> out = new ArrayList<>(methods); out.sort(Comparator.comparingInt(LineAttrNode::getSourceLine)); return out; }
public ResourceEntry getByRef(int refId) { ResourceEntry key = new ResourceEntry(refId); int index = Collections.binarySearch(list, key, Comparator.comparingInt(ResourceEntry::getId)); if (index < 0) { return null; } return list.get(index); }
public ParameterTrieExtender(MethodTree methodTree) { this.methodTree = methodTree; this.inputParameters = new TreeSet<>(comparingInt(Parameter::position)); this.outputParameters = new ArrayList<>(); }
public String usage() { StringBuilder sb = new StringBuilder(); if ( !namedArgs.isEmpty() ) { sb.append( namedArgs.values().stream().map( NamedArgument::usage ).collect( Collectors.joining( " " ) ) ); } if ( !positionalArgs.isEmpty() ) { sb.append( " " ); positionalArgs.sort( Comparator.comparingInt( PositionalArgument::position ) ); sb.append( positionalArgs.stream().map( PositionalArgument::usage ).collect( Collectors.joining( " " ) ) ); } return sb.toString().trim(); }
public FacetLayerPreview(WorldGenerator worldGenerator, List<FacetLayer> facetLayers) { this.worldGenerator = worldGenerator; this.facetLayers = facetLayers.stream() .sorted(Comparator.comparingInt(layer -> layer.getClass().getAnnotation(Renders.class).order())) .collect(Collectors.toList()); }
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)); }
private static ConstraintSemantics loadConstraintSemantics() { Iterable<ConstraintSemantics> semantics = Service.load( ConstraintSemantics.class ); List<ConstraintSemantics> candidates = Iterables.asList( semantics ); checkState( !candidates.isEmpty(), format( "At least one implementation of %s should be available.", ConstraintSemantics.class ) ); return Collections.max( candidates, Comparator.comparingInt( ConstraintSemantics::getPriority ) ); }
@Override public Description report( Set<MethodTree> affectedTrees, SuggestedFix fix, VisitorState state, BugChecker checker) { return affectedTrees.stream() .min(Comparator.comparingInt(t -> ((JCTree) t).getStartPosition())) .map(t -> checker.describeMatch(t.getModifiers(), fix)) .orElse(NO_MATCH); } },
@JsonCreator public CustomTierSelectorStrategy( @JacksonInject ServerSelectorStrategy serverSelectorStrategy, @JacksonInject CustomTierSelectorStrategyConfig config ) { super(serverSelectorStrategy); final Map<Integer, Integer> lookup = new HashMap<>(); int pos = 0; for (Integer integer : config.getPriorities()) { lookup.put(integer, pos); pos++; } this.comparator = Comparator.comparingInt(lookup::get); }
/** * Find all in after of the hooks * * @param path request path */ public List<Route> getAfter(String path) { String cleanPath = parsePath(path); List<Route> afters = hooks.values().stream() .flatMap(Collection::stream) .sorted(Comparator.comparingInt(Route::getSort)) .filter(route -> route.getHttpMethod() == HttpMethod.AFTER && matchesPath(route.getPath(), cleanPath)) .collect(Collectors.toList()); this.giveMatch(path, afters); return afters; }
/** * Find all in before of the hook * * @param path request path */ public List<Route> getBefore(String path) { String cleanPath = parsePath(path); List<Route> collect = hooks.values().stream() .flatMap(Collection::stream) .sorted(Comparator.comparingInt(Route::getSort)) .filter(route -> route.getHttpMethod() == HttpMethod.BEFORE && matchesPath(route.getPath(), cleanPath)) .collect(Collectors.toList()); this.giveMatch(path, collect); return collect; }
public Set<ContentPack> loadAllLatest() { final Set<ContentPack> allContentPacks = loadAll(); final ImmutableMultimap.Builder<ModelId, ContentPack> byIdBuilder = ImmutableMultimap.builder(); for (ContentPack contentPack : allContentPacks) { byIdBuilder.put(contentPack.id(), contentPack); } final ImmutableMultimap<ModelId, ContentPack> contentPacksById = byIdBuilder.build(); final ImmutableSet.Builder<ContentPack> latestContentPacks = ImmutableSet.builderWithExpectedSize(contentPacksById.keySet().size()); for (ModelId id : contentPacksById.keySet()) { final ImmutableCollection<ContentPack> contentPacks = contentPacksById.get(id); final ContentPack latestContentPackRevision = Collections.max(contentPacks, Comparator.comparingInt(Revisioned::revision)); latestContentPacks.add(latestContentPackRevision); } return latestContentPacks.build(); }
public static QueryExecutionEngine initialize( Dependencies deps, GraphDatabaseAPI graphAPI, Iterable<QueryEngineProvider> providers ) { List<QueryEngineProvider> engineProviders = asList( providers ); engineProviders.sort( Comparator.comparingInt( QueryEngineProvider::enginePriority ) ); QueryEngineProvider provider = Iterables.firstOrNull( engineProviders ); if ( provider == null ) { return noEngine(); } QueryExecutionEngine engine = provider.createEngine( deps, graphAPI ); return deps.satisfyDependency( engine ); }
public Stages latestStagesInRunOrder() { Stages latestRunStages = new Stages(); for (Stage stage: this) { if(stage.isLatestRun()) { latestRunStages.add(stage); } } latestRunStages.sort(Comparator.comparingInt(Stage::getOrderId)); return latestRunStages; } }
@Test(timeOut = 5000) public void testMergeSortedEmptyStreamsWithFinishedOnly() { List<ProcessState<Integer>> firstStream = ImmutableList.of( ProcessState.finished()); List<ProcessState<Integer>> secondStream = ImmutableList.of( ProcessState.finished()); WorkProcessor<Integer> mergedStream = WorkProcessorUtils.mergeSorted( ImmutableList.of(processorFrom(firstStream), processorFrom(secondStream)), Comparator.comparingInt(firstInteger -> firstInteger)); // before assertFalse(mergedStream.isBlocked()); assertFalse(mergedStream.isFinished()); assertFinishes(mergedStream); }
private String printStatusesAndTypes(@Nullable Set<NodeHealth> nodeHealths) { if (nodeHealths == null) { return "<null>"; } return nodeHealths.stream() // sort by type then status for debugging convenience .sorted(Comparator.<NodeHealth>comparingInt(s1 -> s1.getDetails().getType().ordinal()) .thenComparingInt(s -> s.getStatus().ordinal())) .map(s -> ImmutableList.of(s.getDetails().getType().name(), s.getStatus().name())) .map(String::valueOf) .collect(Collectors.joining(",")); }