Example usage for java.util Map forEach

List of usage examples for java.util Map forEach

Introduction

In this page you can find the example usage for java.util Map forEach.

Prototype

default void forEach(BiConsumer<? super K, ? super V> action) 

Source Link

Document

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.

Usage

From source file:org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource.java

/**
 * Set a name/attribute map, consisting of method names
 * (e.g. "myMethod") and TransactionAttribute instances
 * (or Strings to be converted to TransactionAttribute instances).
 * @see TransactionAttribute/*from w w w. j  a  v  a2  s  . com*/
 * @see TransactionAttributeEditor
 */
public void setNameMap(Map<String, TransactionAttribute> nameMap) {
    nameMap.forEach(this::addTransactionalMethod);
}

From source file:org.kamranzafar.spring.wpapi.client.BaseService.java

protected URI buildUri(String uri, Map<String, String> params) {
    UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(uri);

    params.forEach((k, v) -> uriComponentsBuilder.queryParam(k, v));

    return uriComponentsBuilder.build().toUri();
}

From source file:org.apache.samza.util.EmbeddedTaggedRateLimiter.java

@Override
public void acquire(Map<String, Integer> tagToCreditsMap) {
    ensureTagsAreValid(tagToCreditsMap);
    tagToCreditsMap.forEach((tag, numberOfCredits) -> tagToRateLimiterMap.get(tag).acquire(numberOfCredits));
}

From source file:org.jmingo.document.id.IdFieldGenerator.java

private void generateIdForMap(Map<?, ?> objects) {
    objects.forEach((key, val) -> {
        generateId(key);/* w w w. ja va 2s.  c  om*/
        generateId(val);
    });
}

From source file:it.smartcommunitylab.aac.oauth.ExtOAuth2SuccessHandler.java

@SuppressWarnings("unchecked")
private void flatten(Map<String, Object> map, String pre, Map<String, Object> result) {
    String prefix = pre.length() > 0 ? (pre + ".") : "";
    map.forEach((k, v) -> {
        if (v != null && (v instanceof Map))
            flatten((Map<String, Object>) v, prefix + k, result);
        else/*from  w  w  w.  j  av  a  2s .  c om*/
            result.put(prefix + k, v);
    });
}

From source file:org.trustedanalytics.utils.hdfs.HdfsConfigFactory.java

private Configuration getConfigFromCf() throws IOException {
    Configuration hadoopConfig = new Configuration(true);

    Map<String, String> config = confHelper.getConfigurationFromEnv(ConfigurationLocator.HADOOP);

    config.forEach(hadoopConfig::set);
    return hadoopConfig;
}

From source file:org.eclipse.winery.repository.backend.filebased.ConfigurationBasedNamespaceManager.java

@Override
public void replaceAll(Map<String, NamespaceProperties> map) {
    this.clear();
    map.forEach(this::setNamespaceProperties);
}

From source file:utybo.branchingstorytree.swing.OpenBST.java

/**
 * Load the default language (which should be English) as well as the user's
 * language. We avoid loading all the language files to avoid having our RAM
 * usage blowing up.//from  www  .  j  a va  2s.com
 *
 * @param userCustomLanguage
 *            The language to use in the application, which must be one
 *            defined in the langs.json file
 */
private static void loadLang(final String userCustomLanguage) {
    final Map<String, String> languages = new Gson()
            .fromJson(
                    new InputStreamReader(OpenBST.class.getResourceAsStream(
                            "/utybo/branchingstorytree/swing/lang/langs.json"), StandardCharsets.UTF_8),
                    new TypeToken<Map<String, String>>() {
                    }.getType());
    try {
        Lang.loadTranslationsFromFile(Lang.getDefaultLanguage(), OpenBST.class
                .getResourceAsStream("/utybo/branchingstorytree/swing/lang/" + languages.get("default")));
    } catch (final Exception e) {
        LOG.warn("Exception while loading language file : " + languages.get("default"), e);
    }
    if (userCustomLanguage != null) {
        Lang.setSelectedLanguage(new Locale(userCustomLanguage));
    }
    final Locale userLanguage = Lang.getSelectedLanguage();
    languages.forEach((k, v) -> {
        if (userLanguage.equals(new Locale(k)) && !v.equals(languages.get("default"))) {
            try {
                Lang.loadTranslationsFromFile(userLanguage,
                        OpenBST.class.getResourceAsStream("/utybo/branchingstorytree/swing/lang/" + v));
            } catch (final Exception e) {
                LOG.warn("Exception while loading language file : " + v, e);
            }
        }
    });
}

From source file:net.straylightlabs.archivo.net.MindCommandRecordingFolderItemSearch.java

private List<Series> buildSeriesList(Map<String, List<Recording>> seriesToRecordings) {
    List<Series> series = new ArrayList<>();
    seriesToRecordings.forEach((title, recordings) -> series.add(new Series(title, recordings)));
    return series;
}