Map get - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Map get method.

This code example shows how to use the following methods:get
        XContentBuilder builder = jsonBuilder().startObject();
        completionFieldMapper.toXContent(builder, null).endObject();
        builder.close();
        Map<String, Object> serializedMap = JsonXContent.jsonXContent.createParser(builder.bytes()).mapAndClose();
        Map<String, Object> configMap = (Map<String, Object>) serializedMap.get("completion");
        assertThat(configMap.get("index_analyzer").toString(), is("simple"));
        assertThat(configMap.get("search_analyzer").toString(), is("standard"));
        assertThat(Boolean.valueOf(configMap.get("payloads").toString()), is(true));
        assertThat(Boolean.valueOf(configMap.get("preserve_separators").toString()), is(false));
        assertThat(Boolean.valueOf(configMap.get("preserve_position_increments").toString()), is(true));
        assertThat(Integer.valueOf(configMap.get("max_input_len").toString()), is(14));
    } 
 
    @Test 
    public void testThatSerializationCombinesToOneAnalyzerFieldIfBothAreEqual() throws Exception { 
        String mapping = jsonBuilder().startObject().startObject("type1")
                .startObject("properties").startObject("completion") 
                .field("type", "completion") 
                .field("index_analyzer", "simple") 
                .field("search_analyzer", "simple") 
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:clear, get, size
    @Test 
    public void testDecodeQueryString() { 
        Map<String, String> params = newHashMap();
 
        String uri = "something?test=value";
        RestUtils.decodeQueryString(uri, uri.indexOf('?') + 1, params);
        assertThat(params.size(), equalTo(1));
        assertThat(params.get("test"), equalTo("value"));
 
        params.clear();
        uri = "something?test=value&test1=value1";
        RestUtils.decodeQueryString(uri, uri.indexOf('?') + 1, params);
        assertThat(params.size(), equalTo(2));
        assertThat(params.get("test"), equalTo("value"));
        assertThat(params.get("test1"), equalTo("value1"));
 
        params.clear();
        uri = "something";
        RestUtils.decodeQueryString(uri, uri.length(), params);
        assertThat(params.size(), equalTo(0));

10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:clear, get
        PathTrie<String> trie = new PathTrie<String>();
        trie.insert("/a/{type}", "test1");
        trie.insert("/b/{name}", "test2");
 
        Map<String, String> params = newHashMap();
        assertThat(trie.retrieve("/a/test", params), equalTo("test1"));
        assertThat(params.get("type"), equalTo("test"));
 
        params.clear();
        assertThat(trie.retrieve("/b/testX", params), equalTo("test2"));
        assertThat(params.get("name"), equalTo("testX"));
    } 
 
    @Test 
    public void testSameNameOnDifferentPath() { 
        PathTrie<String> trie = new PathTrie<String>();
        trie.insert("/a/c/{name}", "test1");
        trie.insert("/b/{name}", "test2");
 
        Map<String, String> params = newHashMap();
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get
 
    public String getHeader(String name) {
        if (headers == null) {
            return null; 
        } 
        List<String> vals = headers.get(name);
        if (vals == null || vals.size() == 0) {
            return null; 
        } 
        return vals.iterator().next();
    } 
} 
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:containsKey, get
    public static BlockVector deserialize(Map<String, Object> args) {
        double x = 0;
        double y = 0;
        double z = 0;
 
        if (args.containsKey("x")) {
            x = (Double) args.get("x");
        } 
        if (args.containsKey("y")) {
            y = (Double) args.get("y");
        } 
        if (args.containsKey("z")) {
            z = (Double) args.get("z");
        } 
 
        return new BlockVector(x, y, z);
    } 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get
        this.map.clear();
        return this;
    } 
 
    public V get(K key) {
        return map.get(key);
    } 
 
    public boolean containsKey(K key) {
        return map.containsKey(key);
    } 
 
    public boolean isEmpty() { 
        return map.isEmpty();
    } 
 
    public Map<K, V> map() {
        return this.map;
    } 
 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, put
    @Override 
    public void addHeader(String name, String value) {
        if (customHeaders == null) {
            customHeaders = new HashMap<String, List<String>>(2);
        } 
        List<String> header = customHeaders.get(name);
        if (header == null) {
            header = new ArrayList<String>();
            customHeaders.put(name, header);
        } 
        header.add(value);
    } 
 
    @Override 
    public Map<String, List<String>> getHeaders() {
        return customHeaders;
    } 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:containsKey, get, size
  } 
   
  public void testGetMap() throws IOException { 
    MetricsServlet servlet = new MetricsServlet();
    Map<String, Map<String, List<TagsMetricsPair>>> m = servlet.makeMap(contexts);
    assertEquals("Map missing contexts", 2, m.size());
    assertTrue(m.containsKey("test1"));
    
    Map<String, List<TagsMetricsPair>> m2 = m.get("test1");
     
    assertEquals("Missing records", 1, m2.size());
    assertTrue(m2.containsKey("testRecord"));
    assertEquals("Wrong number of tags-values pairs.", 1, m2.get("testRecord").size());
  } 
   
  public void testPrintMap() throws IOException { 
    StringWriter sw = new StringWriter();
    PrintWriter out = new PrintWriter(sw);
    MetricsServlet servlet = new MetricsServlet();
    servlet.printMap(out, servlet.makeMap(contexts));
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, keySet, size
        return extractMapping(type, root);
    } 
 
    @SuppressWarnings({"unchecked"}) 
    private Tuple<String, Map<String, Object>> extractMapping(String type, Map<String, Object> root) throws MapperParsingException {
        int size = root.size();
        switch (size) {
            case 0: 
                // if we don't have any keys throw an exception 
                throw new MapperParsingException("malformed mapping no root object found"); 
            case 1: 
                break; 
            default: 
                // we always assume the first and single key is the mapping type root 
                throw new MapperParsingException("mapping must have the `type` as the root object"); 
        } 
 
        String rootName = root.keySet().iterator().next();
        if (type == null) {
            type = rootName;

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:containsKey, get, put

Related Map get Questions & Answers:

get Method Overview
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
See Code Examples for other Java 8 Map Methods: