Example usage for java.util Collections unmodifiableMap

List of usage examples for java.util Collections unmodifiableMap

Introduction

In this page you can find the example usage for java.util Collections unmodifiableMap.

Prototype

public static <K, V> Map<K, V> unmodifiableMap(Map<? extends K, ? extends V> m) 

Source Link

Document

Returns an unmodifiable view of the specified map.

Usage

From source file:com.facebook.stetho.dumpapp.Dumper.java

private static Map<String, DumperPlugin> generatePluginMap(Iterable<DumperPlugin> plugins) {
    Map<String, DumperPlugin> map = new HashMap<String, DumperPlugin>();
    for (DumperPlugin plugin : plugins) {
        map.put(plugin.getName(), plugin);
    }/*from  w ww .ja v  a 2s .c  om*/
    return Collections.unmodifiableMap(map);
}

From source file:com.netflix.spinnaker.halyard.Main.java

private static Map<String, Object> buildDefaults() {
    Map<String, String> defaults = new HashMap<>();
    defaults.put("netflix.environment", "test");
    defaults.put("netflix.account", "${netflix.environment}");
    defaults.put("netflix.stack", "test");
    defaults.put("spring.config.node", "${user.home}/.spinnaker/");
    defaults.put("spring.application.name", "halyard");
    defaults.put("spring.config.name", "spinnaker,${spring.application.name}");
    defaults.put("spring.profiles.active", "${netflix.environment},local");
    return Collections.unmodifiableMap(defaults);
}

From source file:Main.java

public static <K, V> Map<K, V> unmodifiableMap(final Map<? extends K, ? extends V> m) {
    if (m == null) {
        return null;
    }/*from  ww w  .  j a  v  a 2  s  .c  o m*/

    return Collections.unmodifiableMap(m);
}

From source file:com.google.code.commons.checksum.AbstractTestCommonsChecksum.java

protected static Map<String, String> toMap(String[][] checksumsArray) {
    Map<String, String> checksums = new HashMap<String, String>();
    for (String[] checksumPair : checksumsArray) {
        checksums.put(checksumPair[0], checksumPair[1]);
    }/*  w w  w . j ava 2  s . c  o m*/
    return Collections.unmodifiableMap(checksums);
}

From source file:cz.muni.fi.pa165.rest.controllers.MainController.java

@RequestMapping(value = "/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public final Map<String, String> getResources() {

    Map<String, String> resourcesMap = new HashMap<>();
    resourcesMap.put("rooms_uri", "/room");
    return Collections.unmodifiableMap(resourcesMap);
}

From source file:com.arrow.acs.client.search.SearchCriteria.java

public Map<String, String> getSimpleCriteria() {
    return Collections.unmodifiableMap(simpleCriteria);
}

From source file:com.netflix.spinnaker.fiat.Main.java

private static Map<String, Object> buildDefaults() {
    Map<String, String> defaults = new HashMap<>();
    defaults.put("netflix.environment", "test");
    defaults.put("netflix.account", "${netflix.environment}");
    defaults.put("netflix.stack", "test");
    defaults.put("spring.config.location", "${user.home}/.spinnaker/");
    defaults.put("spring.application.name", "fiat");
    defaults.put("spring.config.name", "spinnaker,${spring.application.name}");
    defaults.put("spring.profiles.active", "${netflix.environment},local");
    return Collections.unmodifiableMap(defaults);
}

From source file:com.zigbee.framework.common.dto.CodeTextRegistry.java

public Map<String, String> getStatusMap(String code) {
    if (StringUtils.isBlank(code)) {
        return null;
    }//  w ww . ja v  a 2  s  .  c  o  m
    return Collections.unmodifiableMap(codeTextMap.get(code));
}

From source file:com.arrow.acs.client.search.SearchCriteria.java

public Map<String, String[]> getArrayCriteria() {
    return Collections.unmodifiableMap(arrayCriteria);
}

From source file:Main.java

/**
 * Join the two given maps to one by checking if one of the two maps already fulfills everything. Be aware that the
 * newly created collection is unmodifiable but will change if the underlying collections change!
 *
 * @param <K>    The key type/*  ww w .j  a va  2 s.  c  om*/
 * @param <V>    The value type
 * @param first  The first {@link Map} to join
 * @param second The second {@link Map} to join
 *
 * @return A {@link Map} with the joined content (can be one of the given map if the other is empty or null)
 */
public static <K, V> Map<K, V> joinMapUnmodifiable(Map<K, V> first, Map<K, V> second) {
    if (first == null || first.isEmpty()) {
        if (second == null || second.isEmpty()) {
            return Collections.emptyMap();
        } else {
            return Collections.unmodifiableMap(second);
        }
    } else if (second == null || second.isEmpty()) {
        return Collections.unmodifiableMap(first);
    } else {
        Map<K, V> temp = new LinkedHashMap<K, V>(first.size() + second.size());
        temp.putAll(first);
        temp.putAll(second);
        return Collections.unmodifiableMap(temp);
    }
}