java.util.LinkedHashMap.forEach()方法的使用及代码示例

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

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

LinkedHashMap.forEach介绍

暂无

代码示例

代码示例来源:origin: oracle/helidon

private List<Object> createArguments(Config configNode) {
  List<Object> arguments = new ArrayList<>(parameterValueProviders.size());
  parameterValueProviders.forEach((name, propertyWrapper) -> {
    Config subConfig = configNode.get(name);
    Object argument = propertyWrapper
        .get(subConfig)
        .orElseThrow(() -> new ConfigMappingException(configNode.key(),
                               type,
                               "Missing value for parameter '" + name + "'."));
    arguments.add(argument);
  });
  return arguments;
}

代码示例来源:origin: spring-cloud/spring-cloud-gateway

config.weights.forEach((routeId, weight) -> {
  Double nomalizedWeight = weight / (double) weightsSum;
  config.normalizedWeights.put(routeId, nomalizedWeight);

代码示例来源:origin: uber/okbuck

private LinkedHashMap<String, String> repositoryMap(boolean downloadInBuck) {
 LinkedHashMap<String, String> rawRepositories = new LinkedHashMap<>();
 if (!downloadInBuck) {
  return rawRepositories;
 }
 addRepositories(getProject().getRootProject(), rawRepositories);
 getProject()
   .getRootProject()
   .getSubprojects()
   .forEach(
     subProject -> {
      addRepositories(subProject, rawRepositories);
     });
 LinkedHashMap<String, String> filteredRepositories = new LinkedHashMap<>();
 rawRepositories.forEach(
   (key, value) -> {
    if (!filteredRepositories.values().contains(value)) {
     // Skip adding any `file:` repositories since the path would be absolute
     // and will prevent from checking in the generated buckconfig file.
     if (!value.startsWith("file:")) {
      filteredRepositories.put(key, value);
     }
    }
   });
 return filteredRepositories;
}

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

sortedColumns.forEach((key, defn) -> {
  newColumns.put(key, defn);
  if (defn == afterColumn) {

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

private static void computeRulesFacet(Common.Facets.Builder wsFacets, Facets facets, SearchResponseData data) {
 LinkedHashMap<String, Long> facet = facets.get(PARAM_RULES);
 if (facet == null) {
  return;
 }
 Map<Integer, RuleKey> ruleIdsByRuleKeys = data.getRules().stream().collect(uniqueIndex(RuleDefinitionDto::getId, RuleDefinitionDto::getKey));
 Common.Facet.Builder wsFacet = wsFacets.addFacetsBuilder();
 wsFacet.setProperty(PARAM_RULES);
 facet.forEach((ruleId, count) -> wsFacet.addValuesBuilder()
  .setVal(ruleIdsByRuleKeys.get(Integer.parseInt(ruleId)).toString())
  .setCount(count)
  .build());
 wsFacet.build();
}

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

private static void computeProjectsFacet(Common.Facets.Builder wsFacets, Facets facets, SearchResponseData datas) {
 LinkedHashMap<String, Long> facet = facets.get(FACET_PROJECTS);
 if (facet == null) {
  return;
 }
 Common.Facet.Builder wsFacet = wsFacets.addFacetsBuilder();
 wsFacet.setProperty(FACET_PROJECTS);
 facet.forEach((uuid, count) -> {
  ComponentDto component = datas.getComponentByUuid(uuid);
  requireNonNull(component, format("Component has not been found for uuid '%s'", uuid));
  wsFacet.addValuesBuilder()
   .setVal(component.getKey())
   .setCount(count)
   .build();
 });
 wsFacet.build();
}

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

private static void computeStandardFacet(Common.Facets.Builder wsFacets, Facets facets, String facetKey) {
 LinkedHashMap<String, Long> facet = facets.get(facetKey);
 if (facet == null) {
  return;
 }
 Common.Facet.Builder wsFacet = wsFacets.addFacetsBuilder();
 wsFacet.setProperty(facetKey);
 facet.forEach((value, count) -> wsFacet.addValuesBuilder()
  .setVal(value)
  .setCount(count)
  .build());
 wsFacet.build();
}

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

private static void computeAssigneesFacet(Common.Facets.Builder wsFacets, Facets facets, SearchResponseData data) {
 LinkedHashMap<String, Long> facet = facets.get(PARAM_ASSIGNEES);
 if (facet == null) {
  return;
 }
 Common.Facet.Builder wsFacet = wsFacets.addFacetsBuilder();
 wsFacet.setProperty(PARAM_ASSIGNEES);
 facet
  .forEach((userUuid, count) -> {
   UserDto user = data.getUserByUuid(userUuid);
   wsFacet.addValuesBuilder()
    .setVal(user == null ? "" : user.getLogin())
    .setCount(count)
    .build();
  });
 wsFacet.build();
}

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

if (! triedMechs.isEmpty()) {
  final StringBuilder b = new StringBuilder();
  triedMechs.forEach((mechanismName, throwable) -> b.append("\n   ").append(mechanismName).append(": ").append(throwable.toString()));
  triedStr = b.toString();
} else {

代码示例来源:origin: apache/servicecomb-java-chassis

private void addProviderParams(OperationGenerator operationGenerator,
  LinkedHashMap<String, AbstractSerializableParameter<?>> resultParamMap) {
 resultParamMap.forEach((paramName, param) -> operationGenerator.addProviderParameter(param));
}

代码示例来源:origin: org.apache.lucene/lucene-analyzers-common

private void populateInnerFilters(LinkedHashMap<String, Map<String, String>> wrappedFilterArgs) {
 List<TokenFilterFactory> innerFilters = new ArrayList<>();
 wrappedFilterArgs.forEach((filterName, filterArgs) -> {
  int idSuffixPos = filterName.indexOf(FILTER_NAME_ID_SEPARATOR); // Format: SPIname[-id]
  if (idSuffixPos != -1) {                                        // Strip '-id' suffix, if any, prior to SPI lookup
   filterName = filterName.substring(0, idSuffixPos);
  }
  innerFilters.add(TokenFilterFactory.forName(filterName, filterArgs));
 });
 setInnerFilters(innerFilters);
}

代码示例来源:origin: spring-projects/spring-kafka

@Override
public void handle(Exception thrownException, ConsumerRecords<?, ?> data, Consumer<?, ?> consumer,
    MessageListenerContainer container) {
  data.partitions()
      .stream()
      .collect(
          Collectors.toMap(tp -> tp,
              tp -> data.records(tp).get(0).offset(),
              (u, v) -> (long) v,
              LinkedHashMap::new))
      .forEach(consumer::seek);
  throw new KafkaException("Seek to current after exception", thrownException);
}

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

/** Call the action for each (variable, expression) defined.
 *  Not called when there is no expression, just a variable.
 *  Not order preserving.
 */
public void forEachExpr(BiConsumer<Var, Expr> action) {
  exprs.forEach(action);
}

代码示例来源:origin: com.qwazr/qwazr-search

public static LinkedHashMap<String, AnalyzerDefinition> createDefinitionMap(
    final LinkedHashMap<String, CustomAnalyzer.Factory> factoryMap) {
  if (factoryMap == null)
    return null;
  final LinkedHashMap<String, AnalyzerDefinition> definitionMap = new LinkedHashMap<>();
  factoryMap.forEach((name, factory) -> definitionMap.put(name, factory.definition));
  return definitionMap;
}

代码示例来源:origin: com.qwazr/qwazr-search

void fillAnalyzers(final Map<String, AnalyzerFactory> analyzers) {
  if (analyzers == null)
    return;
  this.localAnalyzerFactoryMap.forEach((name, factory) -> {
    if (!analyzers.containsKey(name))
      analyzers.put(name, factory);
  });
}

代码示例来源:origin: com.qwazr/qwazr-search

static Map<String, String> getFields(LinkedHashMap<String, FacetDefinition> facets) {
  if (facets == null || facets.isEmpty())
    return null;
  final Map<String, String> fields = new HashMap<>();
  facets.forEach((field, facetDefinition) -> {
    if (facetDefinition.queries == null) {
      fields.put(field, facetDefinition.genericFieldName == null ? field : facetDefinition.genericFieldName);
    }
  });
  return fields;
}

代码示例来源:origin: com.qwazr/qwazr-search

void fillFields(final Map<String, FieldDefinition> fields) {
  if (fields == null)
    return;
  this.fieldMap.getFieldDefinitionMap().forEach((name, fieldDef) -> {
    if (!fields.containsKey(name))
      fields.put(name, fieldDef);
  });
}

代码示例来源:origin: com.simiacryptus/mindseye

/**
 * Log keys.
 */
public void logKeys() {
 internalNodes.forEach((id, node) -> {
  log.info(String.format("%s : Node[%s]", id, node.getLayer()));
 });
 getLayersById().forEach((id, layer) -> {
  log.info(String.format("%s : %s", id, layer));
 });
}

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

public LexerNode clone() {
  LexerNode node = new LexerNode();
  node.finalTokenName = this.finalTokenName;
  this.actions.forEach((key, value) -> node.actions.put(key.clone(), value.clone()));
  node.ongoingParsing.addAll(this.ongoingParsing);
  return node;
}

代码示例来源:origin: pac4j/play-pac4j

protected Object clearUserProfiles(Object value) {
  if (value instanceof LinkedHashMap<?, ?>) {
    @SuppressWarnings("unchecked")
    LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) value;
    profiles.forEach((name, profile) -> profile.clearSensitiveData());
    return profiles;
  } else {
    CommonProfile profile = (CommonProfile) value;
    profile.clearSensitiveData();
    return profile;
  }
}

相关文章