Example usage for java.util Map size

List of usage examples for java.util Map size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of key-value mappings in this map.

Usage

From source file:com.hula.lang.parser.util.ValidationUtil.java

/**
 * Assert that no parameters are specified for the command
 * /*from  www . jav  a  2s  .c o m*/
 * @param command The command to inspect
 * @param errors A list of error to append to
 */
public static void assertNoParameters(AbstractCommand command, List<ParseError> errors) {
    Map<String, String> parameters = ParserUtil.getParametersFromCommandLine(command.getCommandLine());
    if (parameters.size() != 0) {
        errors.add(new ParseError("No valid parameters for command", command.getLineNumber(),
                command.getCommandLine(), null));
    }
}

From source file:com.hula.lang.parser.util.ValidationUtil.java

/**
 * Assert that at least one parameter is specified for the command
 * /*from  ww  w  .  ja v  a2  s .co m*/
 * @param command The command to inspect
 * @param errors A list of error to append to
 */
public static void assertAtLeastOneParameter(AbstractCommand command, List<ParseError> errors) {
    Map<String, String> parameters = ParserUtil.getParametersFromCommandLine(command.getCommandLine());
    if (parameters.size() == 0) {
        errors.add(new ParseError("At least one key-value pair is required", command.getLineNumber(),
                command.getCommandLine(), null));
    }
}

From source file:net.chrisrichardson.ormunit.hibernate.LocalSessionFactoryBeanUtil.java

public static LocalSessionFactoryBean getLocalSessionFactoryBean(ApplicationContext applicationContext) {
    Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext,
            LocalSessionFactoryBean.class);
    Assert.assertEquals("LocalSessionFactoryBean", 1, beans.size());
    LocalSessionFactoryBean localSessionFactoryBean = (LocalSessionFactoryBean) beans.values().iterator()
            .next();//from   ww w .j  a va 2 s  .c o m
    return localSessionFactoryBean;
}

From source file:monasca.api.infrastructure.persistence.vertica.MetricQueries.java

static String buildDimensionAndClause(Map<String, String> dimensions, String tableToJoinName) {

    StringBuilder sb = null;//  ww  w .ja  v  a  2  s.c om

    if (dimensions != null && dimensions.size() > 0) {

        int numDims = dimensions.size();
        sb = new StringBuilder();
        sb.append(" and " + tableToJoinName + ".dimension_set_id in ")
                .append("(select dimension_set_id from MonMetrics.Dimensions where ");

        for (int i = 0; i < numDims; i++) {
            sb.append("name = :dname").append(i).append(" and value = :dvalue").append(i);
            if (i != (numDims - 1)) {
                sb.append(" or ");
            }
        }
        sb.append(" group by dimension_set_id ").append(" having count(*) = " + numDims + ") ");
    }

    return sb == null ? "" : sb.toString();
}

From source file:com.sequenceiq.ambari.shell.support.TableRenderer.java

private static Map<String, List<String>> convert(Map<String, String> map) {
    Map<String, List<String>> result = new HashMap<String, List<String>>(map.size());
    if (map != null) {
        for (String key : map.keySet()) {
            result.put(key, singletonList(map.get(key)));
        }//from ww w. ja v a  2  s .  c  o  m
    }
    return result;
}

From source file:com.feilong.tools.net.httpclient3.NameValuePairUtil.java

/**
 * map??NameValuePair.//from   w w w  .j a  va2  s  .c  o  m
 *
 * @param params
 *            the params
 * @return if (Validator.isNotNullOrEmpty(params)), will return null
 */
public static NameValuePair[] fromMap(Map<String, String> params) {
    if (Validator.isNotNullOrEmpty(params)) {
        NameValuePair[] nameValuePairs = new NameValuePair[params.size()];
        int i = 0;
        for (Map.Entry<String, String> entry : params.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            nameValuePairs[i] = new NameValuePair(key, value);
            i++;
        }
        return nameValuePairs;
    }
    return null;
}

From source file:com.streamsets.pipeline.stage.processor.kv.redis.RedisStore.java

private static String[] kvToList(Map<String, String> kv) {
    String[] array = new String[kv.size() * 2];

    int i = 0;//from   w  ww  .j a v  a2s.co  m
    for (Map.Entry<String, String> entry : kv.entrySet()) {
        array[2 * i] = entry.getKey();
        array[(2 * i) + 1] = entry.getValue();
        ++i;
    }

    return array;
}

From source file:com.alibaba.openapi.client.util.InvokeUtil.java

/**
 * /* w w w  . j  a va  2  s.c  om*/
 * @param params
 * @param secretKey
 * @param signatureDataPref
 * @return the signature
 */
public static String signatureData(Map<String, Object> params, String secretKey, String signatureDataPref) {
    final List<String> paramValueList = new ArrayList<String>(params.size());
    for (String key : params.keySet()) {
        paramValueList.add(key + params.get(key));
    }
    return signature(paramValueList, secretKey, signatureDataPref);
}

From source file:com.kku.apps.pricesearch.util.SignedHelper.java

private static List<String> createParamsList(Map<String, String> params) {
    List<String> paramsList = new ArrayList<String>(params.size());
    for (Map.Entry<String, String> map : params.entrySet()) {
        paramsList.add(String.format("%s=%s", map.getKey(), map.getValue()));
    }//from  w w w.  j a  v a 2 s.c o  m
    Collections.sort(paramsList);
    return paramsList;
}

From source file:MapUtils.java

/**
 * Sorts map by values in ascending order.
 * //from ww w .j a  v a  2 s.c  o m
 * @param <K>
 *            map keys type
 * @param <V>
 *            map values type
 * @param map
 * @return
 */
public static <K, V extends Comparable<V>> LinkedHashMap<K, V> sortMapByValue(Map<K, V> map) {
    List<Entry<K, V>> sortedEntries = sortEntriesByValue(map.entrySet());
    LinkedHashMap<K, V> sortedMap = new LinkedHashMap<K, V>(map.size());
    for (Entry<K, V> entry : sortedEntries) {
        sortedMap.put(entry.getKey(), entry.getValue());
    }

    return sortedMap;
}