@Override public int compareTo(TotalRankSolverRankingWeight other) { return Comparator .comparingInt(TotalRankSolverRankingWeight::getBetterCount) .thenComparingInt(TotalRankSolverRankingWeight::getEqualCount) .thenComparingInt(TotalRankSolverRankingWeight::getLowerCount) .thenComparing(TotalRankSolverRankingWeight::getSolverBenchmarkResult, totalScoreSolverRankingComparator) // Tie-breaker .compare(this, other); }
@Override public Comparator<ENTITY> thenComparingInt( ToIntFunction<? super ENTITY> keyExtractor) { return asCombined().thenComparingInt(keyExtractor); }
private static String mapToString(List<Map.Entry<String, Integer>> entries) { entries.sort( Comparator.comparing( (Function<Map.Entry<String, Integer>, String>) Map.Entry::getKey ).thenComparingInt(Map.Entry::getValue) ); final StringBuilder builder = new StringBuilder(); for (Map.Entry<String, Integer> entry : entries) { builder.append(' ') .append(entry.getKey()) .append('=') .append(entry.getValue()); } return builder.toString(); } }
@Override public Workflow getWorkflow(String workflowId, boolean includeTasks) { Workflow workflow = getWithTransaction(tx -> readWorkflow(tx, workflowId)); if (workflow != null) { if (includeTasks) { List<Task> tasks = getTasksForWorkflow(workflowId); tasks.sort(Comparator.comparingLong(Task::getScheduledTime).thenComparingInt(Task::getSeq)); workflow.setTasks(tasks); } } return workflow; }
private ListDefinitionsWsResponse doHandle(Request request) { ListDefinitionsRequest wsRequest = toWsRequest(request); Optional<ComponentDto> component = loadComponent(wsRequest); Optional<String> qualifier = getQualifier(component); ListDefinitionsWsResponse.Builder wsResponse = ListDefinitionsWsResponse.newBuilder(); propertyDefinitions.getAll().stream() .filter(definition -> qualifier.map(s -> definition.qualifiers().contains(s)).orElseGet(definition::global)) .filter(definition -> wsRequest.getBranch() == null || SETTING_ON_BRANCHES.contains(definition.key())) .filter(definition -> settingsWsSupport.isVisible(definition.key(), definition, component)) .sorted(comparing(PropertyDefinition::category, String::compareToIgnoreCase) .thenComparingInt(PropertyDefinition::index) .thenComparing(PropertyDefinition::name, String::compareToIgnoreCase)) .forEach(definition -> addDefinition(definition, wsResponse)); return wsResponse.build(); }
.sorted( Comparator.comparing(Map.Entry<Integer, Integer>::getValue, Comparator.reverseOrder()) .thenComparingInt(Map.Entry::getKey)
Comparator.comparing(PartitionInfo::topic).thenComparingInt(PartitionInfo::partition); SortedSet<PartitionInfo> underReplicatedPartitions = new TreeSet<>(comparator); SortedSet<PartitionInfo> offlinePartitions = new TreeSet<>(comparator);
@Override public Workflow getWorkflow(String workflowId, boolean includeTasks) { String json = dynoClient.get(nsKey(WORKFLOW, workflowId)); Workflow workflow = null; if(json != null) { workflow = readValue(json, Workflow.class); recordRedisDaoRequests("getWorkflow", "n/a", workflow.getWorkflowName()); recordRedisDaoPayloadSize("getWorkflow", json.length(),"n/a", workflow.getWorkflowName()); if (includeTasks) { List<Task> tasks = getTasksForWorkflow(workflowId); tasks.sort(Comparator.comparingLong(Task::getScheduledTime).thenComparingInt(Task::getSeq)); workflow.setTasks(tasks); } } return workflow; }
.sorted(Comparator.comparing(Endpoint::weight) .thenComparing(Endpoint::host) .thenComparingInt(Endpoint::port)) .collect(toImmutableList()); final long numEndpoints = this.endpoints.size();
Set<String> excludedTopics = optimizationOptions.excludedTopics(); SortedSet<Broker> candidateBrokers = new TreeSet<>(Comparator.comparingInt((Broker b) -> b.replicas().size()).thenComparingInt(Broker::id));
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(",")); }
.thenComparingInt(bs -> bs.broker().id());
Comparator.comparingDouble((Broker b) -> utilizationPercentage(b, resource())).thenComparingInt(Broker::id)); if (_selfHealingDeadBrokersOnly) { candidateBrokers.addAll(clusterModel.aliveBrokers()); if (actionType == LEADERSHIP_MOVEMENT) { eligibleBrokers = new TreeSet<>(Comparator.comparingDouble((Broker b) -> utilizationPercentage(b, resource())) .thenComparingInt(Broker::id)); clusterModel.partition(replica.topicPartition()).followerBrokers().forEach(b -> { if (candidateBrokers.contains(b)) {
@Override public Traversal.Admin<Object, Object> apply(final Traverser.Admin<Object> traverser) { // optimization to favor processing StarGraph local objects first to limit message passing (GraphComputer only) // TODO: generalize this for future MatchAlgorithms (given that 3.2.0 will focus on RealTimeStrategy, it will probably go there) if (this.onComputer) { final List<Set<String>> labels = traverser.path().labels(); final Set<String> lastLabels = labels.get(labels.size() - 1); Collections.sort(this.bundles, Comparator.<Bundle>comparingLong(b -> Helper.getStartLabels(b.traversal).stream().filter(startLabel -> !lastLabels.contains(startLabel)).count()). thenComparingInt(b -> b.traversalType.ordinal()). thenComparingDouble(b -> b.multiplicity)); } Bundle startLabelsBundle = null; for (final Bundle bundle : this.bundles) { if (!Helper.hasExecutedTraversal(traverser, bundle.traversal) && Helper.hasStartLabels(traverser, bundle.traversal)) { if (bundle.traversalType != TraversalType.MATCH_TRAVERSAL || Helper.hasEndLabel(traverser, bundle.traversal)) return bundle.traversal; else if (null == startLabelsBundle) startLabelsBundle = bundle; } } if (null != startLabelsBundle) return startLabelsBundle.traversal; throw UNMATCHABLE_PATTERN.apply(this.bundles.stream().map(record -> record.traversal).collect(Collectors.toList())); }
@Override public int compareTo(Version v) { if (v == null) { return -1; } return Comparator.comparingInt(Version::getMajor) .thenComparingInt(Version::getMinor) .thenComparingInt(Version::getPatch) .compare(this, v); }
@Override public int compareTo(IpAccessListLineIndex lineIndex) { if (this == lineIndex) { return 0; } return Comparator.comparing(IpAccessListLineIndex::getAcl) .thenComparingInt(IpAccessListLineIndex::getIndex) .compare(this, lineIndex); }
private Comparator<DestContextMapWrapper> comparator() { return Comparator .comparingInt(this::getWidth) .thenComparingInt(this::getHeight) .thenComparing(this::getFrameRate); }
@Override public Comparator<Passage> comparator() { return Comparator.comparing(Passage::getRank).thenComparing(Passage::getUri) .thenComparing(Passage::getBeginSection) .thenComparingInt(Passage::getOffsetInBeginSection) .thenComparing(Passage::getEndSection).thenComparingInt(Passage::getOffsetInEndSection); }
@Override public int compare(ClusterNodeInfo info1, ClusterNodeInfo info2) { // first compare whether the environment matches return Comparator.comparing(this::matchesEnvironment, BOOLEAN_REVERSED) // then compare the clusterIds .thenComparingInt(ClusterNodeInfo::getId).compare(info1, info2); }
/** * Return a Comparator that will order the specified transports in preferred unload order. */ public static Comparator<Unit> getUnloadableTransportsComparator(final Route route, final PlayerId player, final boolean noTies) { return Comparator.comparing(Matches.transportCannotUnload(route.getEnd())::test) .thenComparing(Unit::getOwner, Comparator.comparing(player::equals)) .thenComparing(getDecreasingCapacityComparator()) .thenComparing(TripleAUnit::get, Comparator.comparingInt(TripleAUnit::getMovementLeft)) .thenComparingInt(t -> noTies ? t.hashCode() : 0); }