com.google.common.collect.Multimap.forEach()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(158)

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

Multimap.forEach介绍

[英]Performs the given action for all key-value pairs contained in this multimap. If an ordering is specified by the Multimap implementation, actions will be performed in the order of iteration of #entries(). Exceptions thrown by the action are relayed to the caller.

To loop over all keys and their associated value collections, write Multimaps.asMap(multimap).forEach((key, valueCollection) -> action()).
[中]对该多重映射中包含的所有键值对执行给定操作。如果多重映射实现指定了顺序,则将按照#entries()的迭代顺序执行操作。操作引发的异常将转发给调用方。
要循环遍历所有键及其关联的值集合,请编写多重映射。asMap(多重映射)。forEach((key,valueCollection)->action()。

代码示例

代码示例来源:origin: google/guava

@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
 synchronized (mutex) {
  delegate().forEach(action);
 }
}

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

@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
 synchronized (mutex) {
  delegate().forEach(action);
 }
}

代码示例来源:origin: google/guava

public void testForEach() {
 List<Entry<K, V>> entries = new ArrayList<>();
 multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
 assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}

代码示例来源:origin: google/guava

@CollectionFeature.Require(KNOWN_ORDER)
 public void testForEachOrder() {
  List<Entry<K, V>> entries = new ArrayList<>();
  multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
  assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
 }
}

代码示例来源:origin: prestodb/presto

initialSplits.putAll(sourceSplits);
sourceTasks.forEach((planNodeId, task) -> {
  TaskStatus status = task.getTaskStatus();
  if (status.getState() != TaskState.FINISHED) {

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

/**
 * Opens a new client, completing the provided future only once the client has been opened.
 *
 * @param future the future to be completed once the client is opened
 */
private void openProxy(CompletableFuture<SessionClient> future) {
 log.debug("Opening proxy session");
 proxyFactory.get().thenCompose(proxy -> proxy.connect()).whenComplete((proxy, error) -> {
  if (error == null) {
   synchronized (this) {
    this.log = ContextualLoggerFactory.getLogger(getClass(), LoggerContext.builder(SessionClient.class)
      .addValue(proxy.sessionId())
      .add("type", proxy.type())
      .add("name", proxy.name())
      .build());
    this.session = proxy;
    proxy.addStateChangeListener(this::onStateChange);
    eventListeners.forEach(proxy::addEventListener);
    onStateChange(PrimitiveState.CONNECTED);
   }
   future.complete(this);
  } else {
   recoverTask = context.schedule(Duration.ofSeconds(1), () -> openProxy(future));
  }
 });
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
 synchronized (mutex) {
  delegate().forEach(action);
 }
}

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

public static void init()
{
  done = true;
  MAP.forEach((t, s) -> OreDictionary.registerOre(s, t.toItemStack()));
  MAP.clear(); // No need to keep this stuff around
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
 synchronized (mutex) {
  delegate().forEach(action);
 }
}

代码示例来源:origin: com.github.mike10004/har-replay-test-support

public static void dump(Multimap<String, CharSource> sources, PrintStream out) {
  sources.forEach((tag, source) -> {
    out.format("%n================================================================================%n");
    out.format("%n==== start %-16s ================================================%n", tag);
    out.format("%n================================================================================%n");
    try {
      source.copyTo(out);
    } catch (IOException e) {
      System.err.println(e.toString());
    }
    out.format("%n================================================================================%n");
    out.format("%n==== end   %-16s ================================================%n", tag);
    out.format("%n================================================================================%n");
  });
}

代码示例来源:origin: com.github.mike10004/nanohttpd-server

public NanoHTTPD.Response build() {
  NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(status, contentType.toString(), content.get(), contentLength);
  headers.forEach(response::addHeader);
  return response;
}

代码示例来源:origin: com.google.guava/guava-testlib

public void testForEach() {
 List<Entry<K, V>> entries = new ArrayList<>();
 multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
 assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}

代码示例来源:origin: com.google.guava/guava-testlib

@CollectionFeature.Require(KNOWN_ORDER)
 public void testForEachOrder() {
  List<Entry<K, V>> entries = new ArrayList<>();
  multimap().forEach((k, v) -> entries.add(mapEntry(k, v)));
  assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
 }
}

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

@Override
public TableAnswerElement answer() {
 ParseVendorConfigurationAnswerElement pvcae =
   _batfish.loadParseVendorConfigurationAnswerElement();
 Map<String, ParseStatus> statusMap = pvcae.getParseStatus();
 Rows rows = new Rows();
 Multimap<String, String> fileToHost = TreeMultimap.create();
 pvcae.getFileMap().forEach((hostname, filename) -> fileToHost.put(filename, hostname));
 statusMap.forEach(
   (filename, status) -> rows.add(getRow(filename, status, fileToHost.get(filename))));
 TableAnswerElement answerElement = new TableAnswerElement(TABLE_METADATA);
 answerElement.postProcessAnswer(_question, rows.getData());
 return answerElement;
}

代码示例来源:origin: io.prestosql/presto-main

initialSplits.putAll(sourceSplits);
sourceTasks.forEach((planNodeId, task) -> {
  TaskStatus status = task.getTaskStatus();
  if (status.getState() != TaskState.FINISHED) {

代码示例来源:origin: prestosql/presto

initialSplits.putAll(sourceSplits);
sourceTasks.forEach((planNodeId, task) -> {
  TaskStatus status = task.getTaskStatus();
  if (status.getState() != TaskState.FINISHED) {

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

_interfacesBySecurityLevel.forEach(
  (level, iface) -> {
   String zoneName = computeSecurityLevelZoneName(level);

相关文章