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.apache.giraph.examples.RandomWalkTestUtils.java

/**
 * Parse steady state probabilities./* w  ww  . jav a2  s  .  com*/
 * @param results The steady state probabilities in text format.
 * @return A map representation of the steady state probabilities.
 */
public static Map<Long, Double> parseSteadyStateProbabilities(Iterable<String> results) {
    Map<Long, Double> result = Maps.newHashMap();
    for (String s : results) {
        String[] tokens = s.split("\\t");
        Long id = Long.parseLong(tokens[0]);
        Double value = Double.parseDouble(tokens[1]);
        result.put(id, value);
    }
    return result;
}

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

/**
 * searchParamskey?OPERATOR_FIELDNAME//from w  ww.  j a  v a  2  s.c o  m
 */
public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) {
    Reporter reporter = BeanContextUtil.getBean(Reporter.class);
    reporter.reporter(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;
}

From source file:controllers.AdminDashboard.java

@Restrictions({ @Restrict("SYSTEM_MONITOR"), @Restrict("SYSTEM_ADMIN"), @Restrict("RESTRICTED_SYSTEM_ADMIN") })
public static void version() {
    License license = AdminDashboardUtils.getLicense();
    Map<String, Promise<?>> promises = Maps.newHashMap();
    promises.put("clusterInfo", AdminDashboardUtils.clusterInfo());
    trySetRenderArgs(promises);// www  . j  a v a  2 s . co  m
    // Add lastUpdated render args after promises are redeemed
    Date clusterInfoLastUpdated = AdminDashboardUtils.getClusterInfoLastUpdated();
    render(license, clusterInfoLastUpdated);
}

From source file:com.cloudera.exhibit.core.simple.SimpleExhibit.java

public static SimpleExhibit of(String name, Frame frame, Object... args) {
    Map<String, Frame> m = Maps.newHashMap();
    m.put(name, frame);/*from   www  . ja v a2s.  co  m*/
    for (int i = 0; i < args.length; i += 2) {
        m.put(args[i].toString(), (Frame) args[i + 1]);
    }
    return new SimpleExhibit(Obs.EMPTY, m);
}

From source file:org.gvnix.web.datatables.util.querydsl.HibernateSpatialSupport.java

public static Map<Operator<?>, String> getSpatialOps(String prefix, boolean asFunction) {
    if (spatialOps != null) {
        return spatialOps;
    }//from  w w w  . ja v  a2s .  c om
    Map<Operator<?>, String> ops = Maps.newHashMap();

    // Initialize spatialOps whatever exception found
    spatialOps = ops;
    try {
        // Check for 3.4.1 QueryDSL required constructor
        OperatorImpl.class.getConstructor(String.class, String.class);
    } catch (NoSuchMethodException ex) {
        LOGGER.warn("No Hibernate Spatial supported added: Check queryDSL library version");
        LOGGER.debug("Exception Initializing Hibernate Spatial support", ex);
        return ops;
    }

    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}) = true");
    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;
}

From source file:net.diogobohm.timed.api.ui.image.ImageLoader.java

private ImageLoader() {
    imageMap = Maps.newHashMap();
}

From source file:com.palantir.atlasdb.console.AtlasConsoleBinder.java

public static Binding create(Binding binding, Object... modules) {
    Map<String, String> topicToHelpMap = Maps.newHashMap();
    for (Object module : modules) {
        AtlasConsoleModule m = createModule(module);
        for (Map.Entry<String, Closure> e : m.getBindings().entrySet()) {
            binding.setVariable(e.getKey(), e.getValue());
        }//from w  w w . j  a v a2  s.co  m
        topicToHelpMap.putAll(m.getHelp());
    }
    binding.setVariable("help", new HelpClosure(binding, topicToHelpMap));
    return binding;
}

From source file:org.robobinding.viewattribute.listview.SparseBooleanArrayUtils.java

public static Map<Integer, Boolean> toMap(SparseBooleanArray array) {
    Map<Integer, Boolean> map = Maps.newHashMap();
    for (int i = 0; i < array.size(); i++) {
        map.put(array.keyAt(i), array.valueAt(i));
    }/* w  w  w .j a  v a  2  s  . c om*/
    return map;
}

From source file:org.jetbrains.kotlin.types.SubstitutionUtils.java

/**
 * Builds a context with all the supertypes' parameters substituted
 */// w  ww.j a  v  a  2  s .c o m
@NotNull
public static TypeSubstitutor buildDeepSubstitutor(@NotNull KotlinType type) {
    Map<TypeConstructor, TypeProjection> substitution = Maps.newHashMap();
    TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution);
    // we use the mutability of the map here
    fillInDeepSubstitutor(type, typeSubstitutor, substitution, null);
    return typeSubstitutor;
}

From source file:org.sakaiproject.nakamura.util.MapUtils.java

/**
 * Converts a name value string delimited with = and ; into an immutable map.
 * /*from   w  w w .  j a  va 2  s . co m*/
 * @param values
 *          the contents of the map
 * @return an immutable map.
 */
public static Map<String, String> convertToImmutableMap(String values) {
    Map<String, String> m = Maps.newHashMap();
    String[] templates = StringUtils.split(values, ';');
    for (String template : templates) {
        String[] nv = StringUtils.split(template, '=', 2);
        if (nv != null && nv.length > 1) {
            m.put(nv[0].trim(), nv[1].trim());
        }
    }
    return ImmutableMap.copyOf(m);
}