Example usage for com.google.common.collect Maps newHashMap

List of usage examples for com.google.common.collect Maps newHashMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newHashMap.

Prototype

public static <K, V> HashMap<K, V> newHashMap() 

Source Link

Document

Creates a mutable, empty HashMap instance.

Usage

From source file:org.ow2.sirocco.cloudmanager.api.openstack.commons.resource.RequestHelper.java

public static Map<String, List<String>> getPathParameters(JaxRsRequestInfo requestInfos) {
    if (requestInfos != null && requestInfos.getUriInfo() != null
            && requestInfos.getUriInfo().getPathParameters() != null) {
        return requestInfos.getUriInfo().getPathParameters();
    } else {/*w  w  w . j  a v  a2s.c  o m*/
        return Maps.newHashMap();
    }
}

From source file:com.yzsl.repository.account.MenuDao.java

public List<Menu> findMenusBy(String userIdString) {
    String sql = "SELECT t.* FROM tmanagermenu t JOIN tmanageruserfun  a ON a.FunID=t.FunID WHERE a.UserID=:p1";
    Map<String, Object> params = Maps.newHashMap();
    params.put("p1", userIdString);
    return findBySql(sql, params, Menu.class);
}

From source file:com.mysema.query.sql.dml.AbstractMapper.java

protected Map<String, Path<?>> getColumns(RelationalPath<?> path) {
    Map<String, Path<?>> columns = Maps.newHashMap();
    for (Path<?> column : path.getColumns()) {
        columns.put(column.getMetadata().getName(), column);
    }//  w w w. j a  v a  2  s  .c  om
    return columns;
}

From source file:buildcraftAdditions.compat.ModuleManager.java

public ModuleManager() {
    modules = Maps.newHashMap();
}

From source file:com.yiji.openapi.sdk.util.BeanMapper.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public static Map<String, Object> deepMap(Object source, String[] properties) throws Exception {

    Map<String, Object> map = Maps.newHashMap();
    for (String property : properties) {
        if (StringUtils.contains(property, ".")) {
            String currentProperty = StringUtils.substringBefore(property, ".");
            String remainProperties = StringUtils.substringAfter(property, ".");
            Map<String, Object> remainMap = deepMap(BeanUtils.getDeclaredProperty(source, currentProperty),
                    new String[] { remainProperties });
            if (map.get(currentProperty) != null) {
                ((Map) map.get(currentProperty)).putAll(remainMap);
            } else {
                map.put(currentProperty, remainMap);
            }//from w w w  .  j a  va 2s  . com

        } else {
            Object value = BeanUtils.getDeclaredProperty(source, property);
            if (value instanceof Collection) {

            }
            map.put(property, value);
        }
    }
    return map;
}

From source file:edu.ucsc.twitter.DemographicsClassifier.java

private static Map<String, File> getDatasetFiles(String... genders) {
    final Map<String, File> files = Maps.newHashMap();
    final String basepath = TwitterEnvironment.getInstance().getOutputFoldername();
    for (String each : genders) {
        final String nonNullCategory = Preconditions.checkNotNull(each);
        final File file = new File(String.format(basepath + "/dist.%s.first", nonNullCategory));
        if (!file.exists()) {
            Console.streaming().error("unable to find file for " + nonNullCategory);
            throw new RuntimeException();
        }/*from   w  w  w .j a  v  a2 s  .c o  m*/

        files.put(each, file);
    }

    return files;
}

From source file:edu.washington.cs.cupid.capability.CapabilityOutputs.java

public CapabilityOutputs() {
    outputs = Maps.newHashMap();
    named = Maps.newHashMap();
}

From source file:com.dianping.apistatic.Job.CinemaListCrawlerJob.java

@Override
protected void execute() throws Exception {
    Map<Integer, Set<Integer>> shopIdMap = Maps.newHashMap(); // key cityid

    for (int cityId : getCityIds()) {
        log("cinamelist current city: " + cityId);
        CinemaListBuilder cinemaListBuilder = new CinemaListBuilder(cityId);
        cinemaListBuilder.buildCache(cinemaListBuilder.getUrlAndHeader());
        shopIdMap.put(cityId, cinemaListBuilder.getShopIds());
    }/*ww  w  .  j  ava 2 s.  com*/

    if (MapUtils.isNotEmpty(shopIdMap)) {
        writeObjectAsJsonToFile(Constants.SHOPIDMAP_PATH, shopIdMap);
    }

}

From source file:com.textocat.textokit.commons.util.ConfigPropertiesUtils.java

/**
 * Replace ${}-placeholders inside properties values.
 *
 * @param props             target {@link Properties} instance
 * @param placeholderValues//from   ww  w.j av  a  2s.c o  m
 * @param ignoreAbsent      if false then absent values for some placeholder key will
 *                          raise {@link IllegalStateException}
 * @return given {@link Properties} instance
 */
public static Properties replacePlaceholders(Properties props, Map<String, String> placeholderValues,
        boolean ignoreAbsent) {
    Map<String, String> replacements = Maps.newHashMap();
    for (String propKey : props.stringPropertyNames()) {
        String propValue = props.getProperty(propKey);
        Matcher phMatcher = PLACEHOLDER_PATTERN.matcher(propValue);
        StringBuffer sb = new StringBuffer(propValue.length());
        while (phMatcher.find()) {
            String replacement = placeholderValues.get(phMatcher.group(1));
            if (replacement == null) {
                if (ignoreAbsent) {
                    replacement = phMatcher.group();
                } else {
                    throw new IllegalArgumentException(
                            String.format("Can't find value for placeholder %s", phMatcher.group()));
                }
            }
            phMatcher.appendReplacement(sb, Matcher.quoteReplacement(replacement));
        }
        phMatcher.appendTail(sb);
        String resultValue = sb.toString();
        if (!resultValue.equals(propValue)) {
            replacements.put(propKey, resultValue);
        }
    }
    for (String propKey : replacements.keySet()) {
        props.setProperty(propKey, replacements.get(propKey));
    }
    return props;
}

From source file:com.endpoint.lg.support.message.GestureMessages.java

/**
 * Deserializes all gestures from data./*from   w  ww. j a v  a2  s.c o  m*/
 * 
 * @param data
 *          gesture data
 * @return all gestures from the data
 */
public static Map<String, Gesture> deserializeGestures(JsonNavigator data) {
    Map<String, Gesture> gestures = Maps.newHashMap();

    data.down(LeapMotionGestureEndpoint.LEAPMOTION_NAME_GESTURES);

    Map<String, Object> dataGestures = data.getCurrentItem();

    for (String id : dataGestures.keySet()) {
        gestures.put(id, deserializeGesture(data, id));
    }

    data.up();

    return gestures;
}