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:com.mysema.query.spatial.HibernateSpatialSupport.java

public static Map<Operator<?>, String> getSpatialOps(String prefix, boolean asFunction) {
    Map<Operator<?>, String> ops = Maps.newHashMap();
    ops.put(SpatialOps.DIMENSION, "dimension({0})");
    ops.put(SpatialOps.GEOMETRY_TYPE, "geometrytype({0}, {1})");
    ops.put(SpatialOps.SRID, "srid({0})");
    ops.put(SpatialOps.ENVELOPE, "envelope({0})");
    ops.put(SpatialOps.AS_TEXT, "astext({0})");
    ops.put(SpatialOps.AS_BINARY, "asbinary({0})");
    ops.put(SpatialOps.IS_EMPTY, "isempty({0})");
    ops.put(SpatialOps.IS_SIMPLE, "issimple({0})");
    ops.put(SpatialOps.BOUNDARY, "boundary({0})");

    ops.put(SpatialOps.EQUALS, "equals({0}, {1})");
    ops.put(SpatialOps.DISJOINT, "disjoint({0}, {1})");
    ops.put(SpatialOps.INTERSECTS, "intersects({0}, {1})");
    ops.put(SpatialOps.TOUCHES, "touches({0}, {1})");
    ops.put(SpatialOps.CROSSES, "crosses({0}, {1})");
    ops.put(SpatialOps.WITHIN, "within({0}, {1})");
    ops.put(SpatialOps.CONTAINS, "contains({0}, {1})");
    ops.put(SpatialOps.OVERLAPS, "overlaps({0}, {1})");
    ops.put(SpatialOps.RELATE, "relate({0}, {1}, {2})");

    ops.put(SpatialOps.DISTANCE, "distance({0}, {1})");
    ops.put(SpatialOps.BUFFER, "buffer({0}, {1})");
    ops.put(SpatialOps.CONVEXHULL, "convexhull({0})");
    ops.put(SpatialOps.INTERSECTION, "intersection({0}, {1})");
    ops.put(SpatialOps.UNION, "geomunion({0}, {1})");
    ops.put(SpatialOps.DIFFERENCE, "difference({0}, {1})");
    ops.put(SpatialOps.SYMDIFFERENCE, "symdifference({0}, {1})");
    // dwithin({0}, {1}, 2)
    ops.put(SpatialOps.TRANSFORM, "transform({0}, {1})");
    // extent({0})
    return ops;/*  w w  w  .j  a v a 2 s. c  o m*/
}

From source file:com.mysema.query.spatial.hibernate.HibernateSpatialSupport.java

public static Map<Operator<?>, String> getSpatialOps() {
    Map<Operator<?>, String> ops = Maps.newHashMap();
    ops.put(SpatialOps.DIMENSION, "dimension({0})");
    ops.put(SpatialOps.GEOMETRY_TYPE, "geometrytype({0}, {1})");
    ops.put(SpatialOps.SRID, "srid({0})");
    ops.put(SpatialOps.ENVELOPE, "envelope({0})");
    ops.put(SpatialOps.AS_TEXT, "astext({0})");
    ops.put(SpatialOps.AS_BINARY, "asbinary({0})");
    ops.put(SpatialOps.IS_EMPTY, "isempty({0})");
    ops.put(SpatialOps.IS_SIMPLE, "issimple({0})");
    ops.put(SpatialOps.BOUNDARY, "boundary({0})");

    ops.put(SpatialOps.EQUALS, "equals({0}, {1}) = true");
    ops.put(SpatialOps.DISJOINT, "disjoint({0}, {1}) = true");
    ops.put(SpatialOps.INTERSECTS, "intersects({0}, {1}) = true");
    ops.put(SpatialOps.TOUCHES, "touches({0}, {1}) = true");
    ops.put(SpatialOps.CROSSES, "crosses({0}, {1}) = true");
    ops.put(SpatialOps.WITHIN, "within({0}, {1}) = true");
    ops.put(SpatialOps.CONTAINS, "contains({0}, {1}) = true");
    ops.put(SpatialOps.OVERLAPS, "overlaps({0}, {1}) = true");
    ops.put(SpatialOps.RELATE, "relate({0}, {1}, {2}) = true");

    ops.put(SpatialOps.DISTANCE, "distance({0}, {1})");
    ops.put(SpatialOps.BUFFER, "buffer({0}, {1})");
    ops.put(SpatialOps.CONVEXHULL, "convexhull({0})");
    ops.put(SpatialOps.INTERSECTION, "intersection({0}, {1})");
    ops.put(SpatialOps.UNION, "geomunion({0}, {1})");
    ops.put(SpatialOps.DIFFERENCE, "difference({0}, {1})");
    ops.put(SpatialOps.SYMDIFFERENCE, "symdifference({0}, {1})");
    // dwithin({0}, {1}, 2)
    ops.put(SpatialOps.TRANSFORM, "transform({0}, {1})");
    // extent({0})
    return ops;//from w w w  .  j a v  a  2  s  .c o m
}

From source file:com.ykun.commons.utils.collection.MapUtils.java

/**
 * @return the hash map//  w  w  w .  j  a v  a  2 s . c o  m
 * @see com.google.common.collect.Maps#newHashMap
 */
public static <K, V> HashMap<K, V> newHashMap() {
    return Maps.newHashMap();
}

From source file:com.withub.common.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME/* w  w w .ja  v  a2  s. c o m*/
 */
public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) {
    Map<String, SearchFilter> filters = Maps.newHashMap();

    for (Map.Entry<String, Object> entry : searchParams.entrySet()) {
        // 
        String key = entry.getKey();
        Object value = entry.getValue();
        if (value == null || StringUtils.isBlank(value.toString())) {
            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];
        Operator operator = Operator.valueOf(names[0]);

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

    return filters;
}

From source file:org.eclipselabs.recommenders.codesearch.rcp.dslQL2.validation.ValidatorHelper.java

public static Map<String, List<String>> getVarParamUsagesByVarName(Document doc) {
    Map<String, List<String>> m = Maps.newHashMap();

    for (Fieldable f : doc.getFieldables(Fields.USED_AS_PARAMETER_IN_METHODS)) {
        String methodName = f.stringValue().split("\\|")[0];
        String origVarName = f.stringValue().split("\\|")[1];

        if (!m.containsKey(origVarName)) {
            m.put(origVarName, new ArrayList<String>());
        }//from w ww .j av a 2  s. co m

        m.get(origVarName).add(methodName);
    }

    return m;
}

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

/**
 * ??List? (listcopy)// w w w .  j  a  v a 2  s. com
 * 
 * @param list
 * @return
 */
public static <T extends BaseEntity> List<T> toTreeNodeList(List<T> source, Class<T> bean) {
    final Map<String, T> nodes = Maps.newHashMap();
    ConvertUtils.register(new Converter() {
        @SuppressWarnings("hiding")
        @Override
        public <T> T convert(Class<T> arg0, Object arg1) {
            // TODO Auto-generated method stub
            return null;
        }
    }, java.util.Date.class);
    // copy?list?
    List<T> list = CollectionsUtils.copyTo(source, bean);
    // ?
    for (T node : list) {
        node.put("level", -1);
        node.put("hasChild", false);
        node.put("children", new ArrayList<T>());
        nodes.put(node.getString("id"), node);
    }

    final BaseEntity root = new BaseEntity();
    root.put("level", 0);
    root.put("children", new ArrayList<T>());
    root.put("hasChild", false);
    nodes.put("0", (T) root);

    for (T node : list) {
        final T parent = nodes.get(node.getString("parentId"));
        if (parent == null) {
            ((ArrayList<T>) root.get("children")).add(node);
            continue;
            // throw new RuntimeException("?id?");
        } else {
            // ?
            ((List<T>) parent.get("children")).add(node);
        }
    }

    int max = 0;
    for (T node : list) {
        max = Math.max(resolveLevel(node, nodes), max);
    }

    return (List<T>) root.get("children");
}

From source file:com.wxt.news.persistence.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME/* ww  w.j a  v  a2 s . com*/
 */
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 (value == null || (value instanceof String && 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];
        Operator operator = Operator.valueOf(names[0]);

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

    return filters;
}

From source file:cn.cdwx.jpa.persistence.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME/*from  w  w w  . ja v  a 2 s  .c o  m*/
 */
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];
        Operator operator = Operator.valueOf(names[0]);

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

    return filters;
}

From source file:org.one.gene.instrument.persistence.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME/*from  www  .j a v a2  s. c o  m*/
 */
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 (value == null || StringUtils.isBlank(String.valueOf(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];
        Operator operator = Operator.valueOf(names[0]);

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

    return filters;
}

From source file:com.ciwen.xhb.cms.common.persistence.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME//from w  w w .j  av  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.valueOf(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];
        Operator operator = Operator.valueOf(names[0]);

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

    return filters;
}