Example usage for java.util Map get

List of usage examples for java.util Map get

Introduction

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

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:Main.java

public static <T> T carelessGet(Map<String, T> map, String key) {
    if (map == null || key == null) {
        return null;
    } else {//from w  w w.  java 2s. c  o  m
        return map.get(key);
    }
}

From source file:Main.java

public static Bundle toBundle(Map<String, String> input) {
    Bundle output = new Bundle();
    for (String key : input.keySet()) {
        output.putString(key, input.get(key));
    }// w  w  w.j ava 2 s.c o  m
    return output;
}

From source file:domainregistry.AdvancedSearch.java

private static List<String> getQueryParams(Map<String, String> parameters) {
    String res = parameters.get(RESOURCES);
    String schemes = parameters.get(SCHEMES);

    String[] resourceTypes = (res != null) ? res.split(",") : new String[0];
    String[] dataSchemes = (schemes != null) ? schemes.split(",") : new String[0];

    List<String> prefixResourceType = map(Arrays.asList(resourceTypes), RESOURCES_PREFIX);
    List<String> prefixSchemeType = map(Arrays.asList(dataSchemes), SCHEMES_PREFIX);

    List<String> hypertyPrefixParams = new ArrayList<String>(prefixResourceType);
    hypertyPrefixParams.addAll(prefixSchemeType);

    return hypertyPrefixParams;
}

From source file:Main.java

public static void scaleBitmaps(Map<Integer, Bitmap> bitmapMap, float scale) {
    for (Integer key : bitmapMap.keySet()) {
        Bitmap bitmap = bitmapMap.get(key);
        bitmapMap.put(key, scaleBitmap(bitmap, scale));
    }/*from   w w w  .jav a 2 s.c  om*/
}

From source file:Main.java

public static <T> Map<T, Integer> groupCount(Collection<T> data) {
    Map<T, Integer> group = new HashMap<T, Integer>();
    if (data != null) {
        for (T x : data) {
            int value = group.get(x) == null ? 1 : group.get(x) + 1;
            group.put(x, value);// w w  w  .j a va2  s . c o  m
        }
    }
    return group;
}

From source file:Main.java

public static <K> void increaseCount(Map<K, Integer> map, K key, int amount) {
    if (!map.containsKey(key)) {
        map.put(key, 0);//from   ww  w.  ja  v a  2s .  co m
    }

    Integer total = map.get(key);
    total += amount;
    map.put(key, total);
}

From source file:com.salesmanager.core.util.LanguageUtil.java

public static Language getLanguageByCode(String lang) {
    if (lang == null) {
        return null;
    }/*from  w w w . j  a v a  2  s  .  c o m*/
    Map langmap = RefCache.getLanguageswithcode();
    Language l = (Language) langmap.get(lang.toLowerCase());
    return l;
}

From source file:ee.ria.xroad.common.conf.globalconf.AbstractConfigurationPart.java

static final void verifyFieldExists(Map<String, String> headers, String fieldName, String expectedValue) {
    String value = headers.get(fieldName);
    if (StringUtils.isBlank(value)) {
        throw new CodedException(X_INTERNAL_ERROR, "Missing field " + fieldName);
    }//from ww  w .j a v a  2s.  c o  m

    if (expectedValue != null && !expectedValue.equals(value)) {
        throw new CodedException(X_INTERNAL_ERROR, "Field " + fieldName + " must have value " + expectedValue);
    }
}

From source file:io.adeptj.runtime.core.Launcher.java

private static void launchBrowser(Map<String, String> commands) {
    if (Boolean.parseBoolean(commands.get(ARG_OPEN_CONSOLE))) {
        try {/*from w w  w. ja  v a2s .com*/
            Config config = Configs.of().undertow().getConfig(KEY_HTTP);
            Environment.launchBrowser(new URL(String.format(OSGI_CONSOLE_URL, config.getInt(KEY_PORT))));
        } catch (IOException ex) {
            // Just log it, its okay if browser is not launched.
            LoggerFactory.getLogger(Launcher.class).error("Exception while launching browser!!", ex);
        }
    }
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.provider.KubernetesModelUtil.java

private static boolean stateEquals(Map<String, String> health, HealthState state) {
    String healthState = health.get("state");
    return healthState != null && healthState.equals(state.name());
}