java.util.Comparator.thenComparingInt()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中java.util.Comparator.thenComparingInt()方法的一些代码示例,展示了Comparator.thenComparingInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Comparator.thenComparingInt()方法的具体详情如下:
包路径:java.util.Comparator
类名称:Comparator
方法名:thenComparingInt

Comparator.thenComparingInt介绍

暂无

代码示例

代码示例来源:origin: kiegroup/optaplanner

@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);
}

代码示例来源:origin: speedment/speedment

@Override
public Comparator<ENTITY> thenComparingInt(
    ToIntFunction<? super ENTITY> keyExtractor) {
  return asCombined().thenComparingInt(keyExtractor);
}

代码示例来源:origin: apache/flink

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();
  }
}

代码示例来源:origin: Netflix/conductor

@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;
}

代码示例来源:origin: SonarSource/sonarqube

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();
}

代码示例来源:origin: runelite/runelite

.sorted(
  Comparator.comparing(Map.Entry<Integer, Integer>::getValue, Comparator.reverseOrder())
      .thenComparingInt(Map.Entry::getKey)

代码示例来源:origin: linkedin/cruise-control

Comparator.comparing(PartitionInfo::topic).thenComparingInt(PartitionInfo::partition);
SortedSet<PartitionInfo> underReplicatedPartitions = new TreeSet<>(comparator);
SortedSet<PartitionInfo> offlinePartitions = new TreeSet<>(comparator);

代码示例来源:origin: Netflix/conductor

@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;
}

代码示例来源:origin: line/armeria

.sorted(Comparator.comparing(Endpoint::weight)
        .thenComparing(Endpoint::host)
        .thenComparingInt(Endpoint::port))
    .collect(toImmutableList());
final long numEndpoints = this.endpoints.size();

代码示例来源:origin: linkedin/cruise-control

Set<String> excludedTopics = optimizationOptions.excludedTopics();
SortedSet<Broker> candidateBrokers = new TreeSet<>(Comparator.comparingInt((Broker b) -> b.replicas().size()).thenComparingInt(Broker::id));

代码示例来源:origin: SonarSource/sonarqube

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(","));
}

代码示例来源:origin: linkedin/cruise-control

.thenComparingInt(bs -> bs.broker().id());

代码示例来源:origin: linkedin/cruise-control

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)) {

代码示例来源:origin: apache/tinkerpop

@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()));
}

代码示例来源:origin: OpenNMS/opennms

@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);
}

代码示例来源:origin: batfish/batfish

@Override
public int compareTo(IpAccessListLineIndex lineIndex) {
 if (this == lineIndex) {
  return 0;
 }
 return Comparator.comparing(IpAccessListLineIndex::getAcl)
   .thenComparingInt(IpAccessListLineIndex::getIndex)
   .compare(this, lineIndex);
}

代码示例来源:origin: DSRCorporation/imf-conversion

private Comparator<DestContextMapWrapper> comparator() {
  return Comparator
      .comparingInt(this::getWidth)
      .thenComparingInt(this::getHeight)
      .thenComparing(this::getFrameRate);
}

代码示例来源:origin: oaqa/baseqa

@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);
}

代码示例来源:origin: apache/jackrabbit-oak

@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);
}

代码示例来源:origin: triplea-game/triplea

/**
 * 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);
}

相关文章