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

/**
 * Copy value if it exists (is not <code>null</code>) from the source map.
 *
 * @param <K>/*from   ww w.ja  va  2  s  .  co  m*/
 *            the key type
 * @param <V>
 *            the value type
 * @param source
 *            the source
 * @param sourceKey
 *            the source key
 * @param target
 *            the target
 * @param targetKey
 *            the target key
 * @return true, if successful
 */
public static <K, V> boolean copyValueIfExist(Map<K, V> source, K sourceKey, Map<K, V> target, K targetKey) {
    V v = source.get(sourceKey);
    if (v != null) {
        target.put(targetKey, v);
        return true;
    }
    return false;
}

From source file:Main.java

public static Object get(String key) {
    Map<String, Object> maps = threadLocalHolder.get();
    if (null == maps) {
        return null;
    }//from   w ww .j av  a2  s  .co  m
    return maps.get(key);
}

From source file:Main.java

public static <K, V> V safeGet(Map<K, V> map, K key) {
    if (map == null) {
        return null;
    } else {/*from   w ww .j  a v a  2 s.co  m*/
        return map.containsKey(key) ? map.get(key) : null;
    }
}

From source file:Main.java

public static Bundle mapToBundle(Map<String, String> map) {
    Bundle bundle = new Bundle();
    for (String key : map.keySet()) {
        bundle.putString(key, map.get(key));
    }//w w  w  .  ja  v  a  2 s  .  c  o m
    return bundle;
}

From source file:com.dropbox.presto.kafka.KafkaTableHandle.java

public static boolean kafkaTableMarkPresent(Map<String, String> props) {
    String kafkaMark = props.get(KafkaTableProperties.kafkaTableMarker);
    return kafkaMark != null && kafkaMark.equalsIgnoreCase("true");
}

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

public static byte[] hexToBytes(Map<String, String> checksumMap, String algorithm) throws DecoderException {
    return Hex.decodeHex(checksumMap.get(algorithm).toCharArray());
}

From source file:com.splicemachine.db.impl.ast.FixSubqueryColRefs.java

public static <K, V> Map<K, List<V>> appendVal(Map<K, List<V>> m, K k, V v) {
    List<V> vals = m.get(k);
    if (vals == null) {
        vals = Lists.newLinkedList();//from   w w  w  .  j  av  a  2 s  .  c  om
        m.put(k, vals);
    }
    vals.add(v);
    return m;
}

From source file:Main.java

public static <T> T get(String key) {
    Map<String, Object> map = _local.get();
    if (map == null) {
        return null;
    } else {/*from w w w. j av a 2 s  .c o m*/
        return (T) map.get(key);
    }
}

From source file:Main.java

public static <K> Map safeGetMap(Map<K, Object> map, K key) {
    if (map == null) {
        return null;
    } else {// w w w .  j a va2s.c  o m
        return map.containsKey(key) ? (Map) map.get(key) : null;
    }
}

From source file:Main.java

/**
 * @param mathExpectation math expectation for full list
 * @return dispersion on full array/*from ww w  . j a v a  2s.c o m*/
 */
private static double dispersionForFull(double mathExpectation, Map<String, Long> pressingLength) {
    double sum = 0.0;
    for (String key : pressingLength.keySet()) {
        double x = pressingLength.get(key) - mathExpectation;
        sum += x * x;
    }
    return sqrt(sum / (pressingLength.size() - 1));
}