Example usage for java.util Map containsKey

List of usage examples for java.util Map containsKey

Introduction

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

Prototype

boolean containsKey(Object key);

Source Link

Document

Returns true if this map contains a mapping for the specified key.

Usage

From source file:flink.benchmark.AdvertisingTopologyNative.java

private static String getKafkaBrokers(Map conf) {
    if (!conf.containsKey("kafka.brokers")) {
        throw new IllegalArgumentException("No kafka brokers found!");
    }//ww w .  j  ava  2 s  .c om
    if (!conf.containsKey("kafka.port")) {
        throw new IllegalArgumentException("No kafka port found!");
    }
    return listOfStringToString((List<String>) conf.get("kafka.brokers"),
            String.valueOf(conf.get("kafka.port")));
}

From source file:Main.java

public static boolean isCheckMapState(Map<String, String> value) {
    if (value == null) {
        return false;
    }/*from www.  ja  v  a  2  s  . c  o m*/
    if (value.isEmpty()) {
        return false;

    }
    if (value.containsKey("status") && value.get("status").equals("0")) {
        return true;
    } else {
        return false;
    }

}

From source file:Main.java

public static <K, V> void putIfAbsent(Map<K, V> from, Map<K, ? super V> to) {
    if (from == null || to == null) {
        return;//from   ww  w.j av a  2 s.  c o  m
    }
    for (Map.Entry<K, V> entry : from.entrySet()) {
        if (!to.containsKey(entry.getKey())) {
            to.put(entry.getKey(), entry.getValue());
        }
    }
}

From source file:ai.susi.tools.JsonSignature.java

public static void removeSignature(Map<String, byte[]> obj) {
    if (obj.containsKey(signatureString))
        obj.remove(signatureString);//from ww w.  jav  a  2s.c  o  m
}

From source file:ai.susi.tools.JsonSignature.java

public static boolean hasSignature(Map<String, byte[]> obj) {
    return obj.containsKey(signatureString);
}

From source file:io.cloudslang.content.amazon.utils.OutputsUtil.java

public static Map<String, String> getValidResponse(Map<String, String> queryMapResult) {
    if (queryMapResult != null) {
        if (queryMapResult.containsKey(STATUS_CODE) && (valueOf(SC_OK).equals(queryMapResult.get(STATUS_CODE)))
                && queryMapResult.containsKey(RETURN_RESULT) && !isEmpty(queryMapResult.get(RETURN_RESULT))) {
            queryMapResult.put(RETURN_CODE, SUCCESS);
        } else {//w ww .j a  v  a 2  s  .  c  o  m
            queryMapResult.put(RETURN_CODE, FAILURE);
        }
        return queryMapResult;
    } else {
        Map<String, String> resultMap = new HashMap<>();
        resultMap.put(EXCEPTION, "Null response!");
        resultMap.put(RETURN_CODE, FAILURE);
        resultMap.put(RETURN_RESULT, "The query returned null response!");
        return resultMap;
    }
}

From source file:com.baidu.rigel.biplatform.ac.util.ThreadLocalPlaceholder.java

/**
 * Remove the object from thread.//w ww  . ja  v a2  s.co m
 * 
 * @param key
 *            key of object
 */
public static void unbindProperty(Object key) {

    if (key == null) {
        throw new IllegalArgumentException("Parameter must not be null");
    }

    // Get Current Thread Map
    Map<Object, Object> propertiesMap = getThreadMap();
    if (!propertiesMap.containsKey(key)) {
        LOG.debug("Removed value [" + key + "] from thread [" + Thread.currentThread().getName() + "]");
    }

    propertiesMap.remove(key);

    LOG.debug("Removed key [" + key + "] from thread [" + Thread.currentThread().getName() + "]");
}

From source file:Main.java

static <T, K> Map<K, List<T>> groupBy(List<T> elements, Function<T, K> classifier) {
    //TODO Implement me
    Map<K, List<T>> map = new HashMap<>();
    List<T> list = new ArrayList<>();
    for (T element : elements) {
        K value = classifier.apply(element);
        if (map.containsKey(value)) {
            map.get(value).add(element);
        } else {/*from w w w .j ava2s  .c  o  m*/
            list.add(element);
            map.put(value, list);
        }
    }
    return map;
}

From source file:com.tdclighthouse.prototype.utils.TdcUtils.java

public static boolean mapContainsKey(@SuppressWarnings("rawtypes") Map map, Object key) {
    return map.containsKey(key);
}

From source file:com.github.mjeanroy.springmvc.view.mustache.commons.ClassUtils.java

/**
 * Get annotation method value.//from   w  ww.  ja  v  a 2  s.  c  o m
 *
 * @param importingClassMetadata Metadata.
 * @param annotationClass        Annotation class to look for.
 * @param name                   Name of method.
 * @param defaultValue           Default value if original value is null.
 * @param <T>                    Type of returned value.
 * @return Annotation value, or default value if original value is null.
 */
@SuppressWarnings("unchecked")
public static <T> T getAnnotationValue(AnnotationMetadata importingClassMetadata, Class annotationClass,
        String name, T defaultValue) {
    Map<String, Object> attributes = importingClassMetadata.getAnnotationAttributes(annotationClass.getName());
    return attributes != null && attributes.containsKey(name) ? (T) attributes.get(name) : defaultValue;
}