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:de.flapdoodle.logparser.collections.Collections.java

public static <K, V> Map<K, V> join(Collection<? extends Map<K, V>> maps) {
    Map<K, V> ret = Maps.newHashMap();
    for (Map<K, V> map : maps) {
        ret = join(ret, map);/* ww w  . j a  va 2s. c  om*/
    }
    return ret;
}

From source file:com.cloudera.exhibit.core.composite.NeighborLookup.java

public static NeighborLookup create(String column, String entity, String... args) {
    Map<String, String> cte = Maps.newHashMap();
    cte.put(column, entity);//from   w ww.j a v  a  2 s . c o  m
    for (int i = 0; i < args.length; i += 2) {
        cte.put(args[i], args[i + 1]);
    }
    return new NeighborLookup(cte);
}

From source file:org.apache.aurora.common.util.testing.FakeBuildInfo.java

public static BuildInfo generateBuildInfo() {
    Map<String, String> buildProperties = Maps.newHashMap();
    buildProperties.put(DATE, DATE);//from   w w w . java  2 s.co m
    buildProperties.put(GIT_REVISION, GIT_REVISION);
    buildProperties.put(GIT_TAG, GIT_TAG);
    return new BuildInfo(buildProperties);
}

From source file:com.thinkgem.jeesite.modules.pms.utils.FeesUtils.java

public static Fees getFees(String id) {
    @SuppressWarnings("unchecked")
    Map<String, Fees> dictMap = (Map<String, Fees>) CacheUtils.get(CACHE_FEES_MAP);
    if (dictMap == null) {
        dictMap = Maps.newHashMap();
        for (Fees fees : feesDao.findAll()) {
            dictMap.put(fees.getId(), fees);
        }//from   ww w .  j a va2  s . com
        CacheUtils.put(CACHE_FEES_MAP, dictMap);
    }
    Fees dictList = dictMap.get(id);
    if (dictList == null) {
        dictList = new Fees();
    }
    return dictList;
}

From source file:com.yunmel.utils.jse.ThreadLocalUtils.java

@SuppressWarnings("unchecked")
public static void set(String attribute, Object value) {
    Map<String, Object> map = (Map<String, Object>) SESSION_MAP.get();
    if (map == null) {
        map = Maps.newHashMap();
        SESSION_MAP.set(map);/*from  w  ww .  j  a v  a  2 s  . co m*/
    }
    map.put(attribute, value);
}

From source file:qa.qcri.nadeef.lab.hc.FixExtensions.java

public static boolean isValidFix(HashSet<Fix> repairContext, List<Fix> fixes) {
    HashMap<Cell, String> modifiedCell = Maps.newHashMap();
    for (Fix fix : fixes) {
        modifiedCell.put(fix.getLeft(), fix.getRightValue());
    }// ww w.j  av a2s . com

    for (Fix fix : repairContext) {
        Cell leftCell = fix.getLeft();
        double leftValue;
        if (modifiedCell.containsKey(leftCell)) {
            String obj = modifiedCell.get(leftCell);
            leftValue = parseValue(obj);
        } else {
            leftValue = getValue(leftCell.getValue());
        }

        double rightValue;
        if (!fix.isRightConstant()) {
            Cell rightCell = fix.getRight();
            if (modifiedCell.containsKey(rightCell)) {
                String obj = modifiedCell.get(rightCell);
                rightValue = parseValue(obj);
            } else {
                rightValue = getValue(rightCell.getValue());
            }
        } else {
            String obj = fix.getRightValue();
            rightValue = parseValue(obj);
        }

        boolean result = false;
        switch (fix.getOperation()) {
        case EQ:
            result = leftValue == rightValue;
            break;
        case LT:
            result = leftValue < rightValue;
            break;
        case LTE:
            result = leftValue <= rightValue;
            break;
        case GT:
            result = leftValue > rightValue;
            break;
        case GTE:
            result = leftValue >= rightValue;
            break;
        case NEQ:
            result = leftValue != rightValue;
            break;
        default:
            assert true;
        }

        // inverse the result to break constraints
        if (!result)
            return false;
    }
    return true;
}

From source file:com.yunmel.syncretic.utils.biz.DealParamUtil.java

/**
 * ??/* w ww .ja  v a  2 s  .  c  om*/
 * 
 * @param params
 * @return
 */
public final static Map<String, Object> dealParam(Map<String, Object> params) {
    if (null != params) {
        if (!params.containsKey(PAGE_NUM_STR)) {
            params.put(PAGE_NUM_STR, PAGE_NUM);
        }

        if (!params.containsKey(PAGE_SIZE_STR)) {
            params.put(PAGE_SIZE_STR, PAGE_SIZE);
        }
    } else {
        params = Maps.newHashMap();
        params.put(PAGE_NUM_STR, PAGE_NUM);
        params.put(PAGE_SIZE_STR, PAGE_SIZE);
    }
    return params;
}

From source file:interactivespaces.master.api.MasterApiMessageSupport.java

/**
 * Get the simple version of a Master API success response.
 *
 * @return a success API response/*ww  w .jav a 2 s .com*/
 */
public static Map<String, Object> getSimpleSuccessResponse() {
    Map<String, Object> response = Maps.newHashMap();

    response.put(MasterApiMessage.MASTER_API_MESSAGE_ENVELOPE_RESULT,
            MasterApiMessage.MASTER_API_RESULT_SUCCESS);

    return response;
}

From source file:org.sonatype.mavenbook.utils.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME/*from   ww  w. jav a  2 s  .  c om*/
 */
public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) {
    Map<String, SearchFilter> filters = Maps.newHashMap();

    for (Entry<String, Object> entry : searchParams.entrySet()) {
        // 
        String key = entry.getKey();
        Object value = entry.getValue();
        if (StringUtils.isBlank((String) value)) {
            continue;
        }

        // operatorfiledAttribute
        String[] names = StringUtils.split(key, "_");
        if (names.length != 2) {
            throw new IllegalArgumentException(key + " is not a valid search filter name");
        }
        String filedName = names[1]; //wu:   a.b.c ?c?
        Operator operator = Operator.valueOf(names[0]);// EQ,LIKE

        // searchFilter
        SearchFilter filter = new SearchFilter(filedName, operator, value);
        filters.put(key, filter);
    }

    return filters;
}

From source file:com.faceye.feature.repository.jpa.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME//  ww w.j a  va 2 s . c o  m
 */
public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) {
    Map<String, SearchFilter> filters = Maps.newHashMap();
    if (MapUtils.isEmpty(searchParams)) {
        return filters;
    }
    for (Entry<String, Object> entry : searchParams.entrySet()) {
        // 
        String key = entry.getKey();
        Object value = entry.getValue();
        //         if (StringUtils.isBlank((String) value)) {
        //            continue;
        //         }

        // operatorfiledAttribute
        String[] names = StringUtils.split(key, "|");
        if (names.length != 2) {
            //            throw new IllegalArgumentException(key + " is not a valid search filter name");
            continue;
        }
        String filedName = names[1];
        Operator operator = Operator.valueOf(names[0]);

        // searchFilter
        SearchFilter filter = new SearchFilter(filedName, operator, value);
        filters.put(key, filter);
    }

    return filters;
}