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:com.inmobi.conduit.distcp.tools.mapred.RetriableFileCopyCommand.java

private static void incrementReceived(byte[] msg, Map<Long, Long> received) {
    long timestamp = AuditUtil.getTimestamp(msg);
    long window = getWindow(timestamp);
    if (timestamp != -1) {
        if (received.containsKey(window)) {
            received.put(window, received.get(window) + 1);
        } else {//from w  w  w.  j av  a 2s .c om
            received.put(window, Long.valueOf(1));
        }
    }
}

From source file:edu.cmu.cs.lti.ark.fn.parsing.DataPrep.java

public static void addFeature(String key, Map<String, Integer> freqmap) {
    if (!freqmap.containsKey(key)) {
        final int numFeatures = freqmap.size();
        freqmap.put(key, numFeatures + 1);
    }/*from w ww  .jav  a  2s .  c  o  m*/
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.annotator.OnlyFilesMatchingPredictionsReader.java

public static Map<String, List<Sequence>> updateFirstTokenCacheFromSequences(List<Sequence> sequences) {
    Map<String, List<Sequence>> result = new HashMap<>();

    // update the cache
    for (Sequence sequence : sequences) {
        String firstToken = sequence.getTokens().get(0).getToken();

        if (!result.containsKey(firstToken)) {
            result.put(firstToken, new ArrayList<Sequence>());
        }//  ww  w  .  j av a 2 s .com

        result.get(firstToken).add(sequence);
    }

    return result;
}

From source file:com.wavemaker.tools.javaservice.JavaServiceDefinition.java

/**
 * Get a list of methods, excluding overloaded ones, biased towards the method with the least number of arguments
 * (in other words, if a method is overloaded, the instance with the fewest arguments is included in the return
 * value)./*  w  ww  .  j  a v  a  2s.c  o m*/
 * 
 * @param allMethods
 * @return
 */
public static Collection<Method> filterOverloadedMethods(List<Method> allMethods) {

    Map<String, Method> methodsMap = new HashMap<String, Method>();
    for (Method method : allMethods) {
        if (methodsMap.containsKey(method.getName())) {
            if (methodsMap.get(method.getName()).getParameterTypes().length > method
                    .getParameterTypes().length) {
                methodsMap.put(method.getName(), method);
            }
        } else {
            methodsMap.put(method.getName(), method);
        }
    }

    return methodsMap.values();
}

From source file:co.cask.cdap.metrics.query.MetricsRequestParser.java

private static boolean isTimeseriesRequest(Map<String, List<String>> queryParams) {
    return queryParams.containsKey(COUNT) || queryParams.containsKey(START_TIME)
            || queryParams.containsKey(END_TIME);
}

From source file:de.xwic.appkit.core.transport.xml.EtoSerializer.java

/**
 * @param proxy/* www. j  a v  a2s  . c  o  m*/
 * @param to
 * @param type
 * @return
 * @throws IntrospectionException
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 */
private static IEntity transferData(final IEntity proxy, final Class<? extends IEntity> type)
        throws IntrospectionException, IllegalArgumentException, IllegalAccessException,
        InvocationTargetException {

    final IEntity result = EntityUtil.createEntity(type);
    Map<String, PropertyDescriptor> objectProp = getMap(result);
    Map<String, PropertyDescriptor> proxyProp = getMap(proxy);
    Set<String> allSet = new HashSet<String>(objectProp.keySet());
    allSet.addAll(proxyProp.keySet());
    allSet.removeAll(IGNORE_PROPERTIES);
    for (String prop : allSet) {
        if (proxyProp.containsKey(prop) && objectProp.containsKey(prop)) {
            Method readMethod = proxyProp.get(prop).getReadMethod();
            Method writeMethod = objectProp.get(prop).getWriteMethod();
            if (readMethod == null || writeMethod == null) {
                System.out.println("Illegal " + prop);
                continue;
            }
            writeMethod.invoke(result, readMethod.invoke(proxy));
        }
    }

    return result;
}

From source file:com.mmj.app.common.cookie.parser.CookieParser.java

/**
 * <pre>//  w ww .  ja  v  a  2  s  .c o  m
 *      ?questCookieCookie?{@link CookieNameEnum}Key,{@link CookieNameHelper}ValueMap
 *      {@link CookieNameHelper}?{@link CookieNameEnum}{@link CookieKeyEnum}
 *      @return Request CookieemptyMap
 * </pre>
 */
public static Map<CookieNameEnum, CookieNameHelper> loadCookie(Cookie... cookies) {
    // Map
    Map<CookieNameEnum, CookieNameHelper> allValues = new HashMap<CookieNameEnum, CookieNameHelper>();
    // Cookie
    Map<String, String> cookieKV = CookieUtils.arrayToMap(cookies);
    // ?CookieName??
    for (CookieNameEnum cookieName : CookieNameEnum.values()) {
        // ?CookieName??
        CookieNameConfig cookieNameConfig = CookieNamePolicyParser.getCookieNamePolicyMap().get(cookieName);
        boolean isCookieExisted = cookieKV.containsKey(cookieNameConfig.getCookieName());
        if (isCookieExisted) {
            String value = cookieKV.get(cookieName.getCookieName());
            CookieNameHelper cookieNameHelper = paserCookieValue(cookieNameConfig, value);
            // ?
            if (cookieNameHelper != null) {
                allValues.put(cookieName, cookieNameHelper);
            }
        }

    }
    return allValues;
}

From source file:com.ms.commons.test.tool.ExportDatabaseData.java

private static void removeFields(Map<String, TableFields> map, List<TableFields> tableFieldList) {
    for (TableFields tfs : tableFieldList) {
        if (map.containsKey(tfs.getTable())) {
            map.get(tfs.getTable()).getFields().removeAll(tfs.getFields());
        }// w ww.j a  va 2 s  . co m
    }
}

From source file:com.uber.hoodie.hive.client.SchemaUtil.java

private static String getPartitionKeyType(Map<String, String> hiveSchema, String partitionKey) {
    if (hiveSchema.containsKey(partitionKey)) {
        return hiveSchema.get(partitionKey);
    }/*ww  w. j  a  v a2s.c o m*/
    // Default the unknown partition fields to be String
    // TODO - all partition fields should be part of the schema. datestr is treated as special. Dont do that
    return "String";
}

From source file:com.epam.catgenome.util.Utils.java

/**
 * Helper method to get Chromosome from Map of Chromosome to String chromosome name, taking into account variations
 * in chromosome naming//from  w  w  w .java2s.co  m
 * @param chromosomeMap a Map of Chromosome to String chromosome name
 * @param chromosomeName a name of a chromosome
 * @return Chromosome from Map of Chromosome to String chromosome name, taking into account variations
 * in chromosome naming
 */
public static Chromosome getFromChromosomeMap(Map<String, Chromosome> chromosomeMap, String chromosomeName) {
    return chromosomeMap.containsKey(chromosomeName) ? chromosomeMap.get(chromosomeName)
            : chromosomeMap.get(changeChromosomeName(chromosomeName));
}