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:io.appform.nautilus.funnel.utils.RegexUtils.java

public static Map<String, List<String>> separateRegexes(final List<String> stages) {
    String regex = "";
    Map<String, List<String>> segments = Maps.newHashMap();
    int i = 0;//w w  w  . j av a  2  s  .  c om
    List<String> items = Lists.newArrayList();
    for (String stage : stages) {
        if (0 == i) {
            regex = String.format("%s.*", PathUtils.transformName(stage));
        } else {
            regex = String.format("%s%s.*", regex, PathUtils.transformName(stage));
        }
        i++;
        items.add(stage);
        segments.put(String.format(".*%s", regex), new ArrayList<>(items));
    }
    return segments;
}

From source file:com.sishuok.es.maintain.push.service.PushApiImpl.java

@Override
public void pushUnreadMessage(final Long userId, Long unreadMessageCount) {
    Map<String, Object> data = Maps.newHashMap();
    data.put("unreadMessageCount", unreadMessageCount);
    pushService.push(userId, data);//  w  w  w  .j av a2 s  .co  m
}

From source file:net.oneandone.maven.plugins.cycles.graph.StronglyConnectedComponents.java

/**
 * Computes strongly connected components.
 * //from   w  w w.  ja v a2s . com
 * @param g a graph
 * @param <V> vertex type
 * @param <E> edge type
 * @return a collection of components
 */
public static <V, E> Collection<Set<V>> strongComponentsAsSets(DirectedGraph<V, E> g) {
    AtomicInteger index = new AtomicInteger(0);
    Stack<V> s = new Stack<V>();
    Map<V, Integer> vindex = Maps.newHashMap();
    Map<V, Integer> vlowlink = Maps.newHashMap();
    List<Set<V>> acc = Lists.newArrayList();
    for (V v : g.getVertices()) {
        if (!vindex.containsKey(v)) {
            tarjan(v, g, index, s, vindex, vlowlink, acc);
        }
    }
    return acc;
}

From source file:org.apache.drill.exec.store.sys.PStoreTestUtil.java

public static void test(PStoreProvider provider) throws Exception {
    PStore<String> store = provider.getStore(
            PStoreConfig.newJacksonBuilder(new ObjectMapper(), String.class).name("sys.test").build());
    String[] keys = { "first", "second" };
    String[] values = { "value1", "value2" };
    Map<String, String> expectedMap = Maps.newHashMap();

    for (int i = 0; i < keys.length; i++) {
        expectedMap.put(keys[i], values[i]);
        store.put(keys[i], values[i]);// w  w  w. j a  v a  2s.  c  o m
    }
    // allow one second for puts to propagate back to cache
    {
        Iterator<Map.Entry<String, String>> iter = store.iterator();
        for (int i = 0; i < keys.length; i++) {
            Entry<String, String> e = iter.next();
            assertTrue(expectedMap.containsKey(e.getKey()));
            assertEquals(expectedMap.get(e.getKey()), e.getValue());
        }

        assertFalse(iter.hasNext());
    }

    {
        Iterator<Map.Entry<String, String>> iter = store.iterator();
        while (iter.hasNext()) {
            iter.next();
            iter.remove();
        }
    }

    // allow one second for deletes to propagate back to cache

    assertFalse(store.iterator().hasNext());
}

From source file:net.diogobohm.timed.api.db.serializer.DBActivitySerializer.java

@Override
public Map<String, Object> serialize(DBActivity object) {
    Map<String, Object> valueMap = Maps.newHashMap();

    valueMap.put("name", object.getName());

    return valueMap;
}

From source file:org.sonar.batch.MavenProjectConverter.java

public static ProjectDefinition convert(List<MavenProject> poms, MavenProject root) {
    Map<String, MavenProject> paths = Maps.newHashMap(); // projects by canonical path to pom.xml
    Map<MavenProject, ProjectDefinition> defs = Maps.newHashMap();

    try {//from  w w  w .  ja v a  2s  .  c om
        for (MavenProject pom : poms) {
            paths.put(pom.getFile().getCanonicalPath(), pom);
            defs.put(pom, convert(pom));
        }

        for (Map.Entry<String, MavenProject> entry : paths.entrySet()) {
            MavenProject pom = entry.getValue();
            for (Object m : pom.getModules()) {
                String moduleId = (String) m;
                File modulePath = new File(pom.getBasedir(), moduleId);
                if (modulePath.exists() && modulePath.isDirectory()) {
                    modulePath = new File(modulePath, "pom.xml");
                }
                MavenProject module = paths.get(modulePath.getCanonicalPath());

                ProjectDefinition parentProject = defs.get(pom);
                ProjectDefinition subProject = defs.get(module);
                if (parentProject == null) {
                    throw new IllegalStateException(UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE);
                }
                if (subProject == null) {
                    throw new IllegalStateException(UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE);
                }
                parentProject.addSubProject(subProject);
            }
        }
    } catch (IOException e) {
        throw new SonarException(e);
    }

    ProjectDefinition rootProject = defs.get(root);
    if (rootProject == null) {
        throw new IllegalStateException(UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE);
    }

    return rootProject;
}

From source file:com.nirmata.workflow.models.Task.java

/**
 * Utility to create a new meta map with the given submit value
 *
 * @param value the submit value/*from   w  w  w . java  2  s .c o  m*/
 * @return new meta map
 */
public static Map<String, String> makeSpecialMeta(long value) {
    Map<String, String> meta = Maps.newHashMap();
    meta.put(META_TASK_SUBMIT_VALUE, Long.toString(value));
    return meta;
}

From source file:org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping.java

public IdentityMapping() {
    this.identityNameToSchemaNode = Maps.newHashMap();
}

From source file:oims.dataBase.ColumnSelector.java

public void addColumn(String columnName, String value) {
    if (itsColumns_ == null) {
        itsColumns_ = Maps.newHashMap();
    }
    itsColumns_.put(columnName, value);
}

From source file:org.sonar.ide.eclipse.internal.core.markers.MarkerUtils.java

public static void createMarkersForViolations(IResource resource, Collection<Violation> violations) {
    for (Violation violation : violations) {
        final Map<String, Object> markerAttributes = Maps.newHashMap();
        markerAttributes.put(IMarker.LINE_NUMBER, violation.getLineId());
        markerAttributes.put(IMarker.MESSAGE, violation.getMessage());
        markerAttributes.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
        markerAttributes.put(IMarker.PRIORITY, IMarker.PRIORITY_LOW);

        Rule rule = violation.getRule();
        markerAttributes.put("rulekey", rule.getKey()); //$NON-NLS-1$
        markerAttributes.put("rulename", rule.getName()); //$NON-NLS-1$
        // Don't use rule.getSeverity() here - see SONARIDE-218
        markerAttributes.put("rulepriority", violation.getSeverity().toString()); //$NON-NLS-1$

        try {/*from www. j  a  va 2s  . co  m*/
            IMarker marker = resource.createMarker(SonarCorePlugin.MARKER_ID);
            marker.setAttributes(markerAttributes);
        } catch (CoreException e) {
            LOG.error(e.getMessage(), e);
        }
    }
}