AbstractMap put - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:put, HashMap.put
 
public abstract class ConfigurationTest { 
    public abstract Configuration getConfig();
 
    public Map<String, Object> getTestValues() {
        HashMap<String, Object> result = new LinkedHashMap<String, Object>();
 
        result.put("integer", Integer.MIN_VALUE);
        result.put("string", "String Value");
        result.put("long", Long.MAX_VALUE);
        result.put("true-boolean", true);
        result.put("false-boolean", false);
        result.put("vector", new Vector(12345.67, 64, -12345.6789));
        result.put("list", Arrays.asList(1, 2, 3, 4, 5));
        result.put("42", "The Answer");
 
        return result;
    } 
 
    /** 
8
CodeRank
This code example shows how to use the following methods:put, put
 
import java.util.LinkedHashMap; 
 
public class QMFStatistic 
{ 
    private final LinkedHashMap<String,Object> _map = new LinkedHashMap<String,Object>();
    private static final String NAME = "name";
    private static final String TYPE = "type";
    private static final String UNIT = "unit";
    private static final String DESCRIPTION = "desc";
 
 
    public QMFStatistic(String name, QMFType type, String unit, String description)
    { 
        _map.put(NAME, name);
        _map.put(TYPE, type.codeValue());
        if(unit != null)
        { 
            _map.put(UNIT, unit);
        } 

7
CodeRank
This code example shows how to use the following methods:put, put
 
import java.util.LinkedHashMap; 
 
public class QMFStatistic 
{ 
    private final LinkedHashMap<String,Object> _map = new LinkedHashMap<String,Object>();
    private static final String NAME = "name";
    private static final String TYPE = "type";
    private static final String UNIT = "unit";
    private static final String DESCRIPTION = "desc";
 
 
    public QMFStatistic(String name, QMFType type, String unit, String description)
    { 
        _map.put(NAME, name);
        _map.put(TYPE, type.codeValue());
        if(unit != null)
        { 
            _map.put(UNIT, unit);
        } 

7
CodeRank
This code example shows how to use the following methods:put, put
        Assert.assertEquals(1, imfs.readAll().size());
    } 
 
    @Test 
    public void testUnitFeatureInitialization2() { 
        LinkedHashMap<String, Feature> map1 = new LinkedHashMap<String, Feature>();
        map1.put("new", new Feature("new", true, "description"));
        map1.put("old", new Feature("old", true, "description"));
        InMemoryFeatureStore imfs = new InMemoryFeatureStore(map1);
        Assert.assertEquals(2, imfs.readAll().size());
        Assert.assertTrue(imfs.toString().contains("old"));
    } 
 
    @Test(expected = IllegalArgumentException.class) 
    public void testUnitFeatureInitialization3() { 
        new InMemoryFeatureStore("invalid.xml"); 
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:put, size, values, Map.put
        } 
        return false; 
    } 
 
    public final Param[] getParametersInfo() { 
        LinkedHashMap map = new LinkedHashMap();
        setupParameters(map);
 
        return (Param[]) map.values().toArray(new Param[map.size()]);
    } 
 
    void setupParameters(LinkedHashMap map) {
        map.put(URLP.key, URLP);
        map.put(HEADERROW.key, HEADERROW);
        map.put(LATCOL.key, LATCOL);
        map.put(LONGCOL.key, LONGCOL);
        map.put(SHEETNAME.key, SHEETNAME);
        map.put(PROJECTION.key, PROJECTION);
    } 
 

6
CodeRank
This code example shows how to use the following methods:put, remove
 
        AbstractMap map1 = new HashMap(0);
        map1.put("key", value);
        assertSame("HashMap(0)", map1.remove("key"), value);
 
        AbstractMap map4 = new IdentityHashMap(1);
        map4.put(key, value);
        assertSame("IdentityHashMap", map4.remove(key), value);
 
        AbstractMap map5 = new LinkedHashMap(122);
        map5.put(key, value);
        assertSame("LinkedHashMap", map5.remove(key), value);
 
        AbstractMap map6 = new TreeMap(new Comparator() {
            // Bogus comparator 
            public int compare(Object object1, Object object2) {
                return 0; 
            } 
        }); 
        map6.put(key, value);
6
CodeRank
This code example shows how to use the following methods:put, put
        IO;
    } 
 
    public class Argument 
    { 
        private final LinkedHashMap<String,Object> _map = new LinkedHashMap<String,Object>();
 
        public Argument(String name, QMFType type)
        { 
            _map.put(NAME, name);
            _map.put(TYPE, type.codeValue());
        } 
 
        public void setRefPackage(String refPackage)
        { 
            _map.put(REF_PACKAGE, refPackage);
        } 
 
        public void setRefClass(String refClass)
        { 
6
CodeRank
This code example shows how to use the following methods:equals, put
    } 
 
    public void test_equalsLjava_lang_Object() { 
        AbstractMap<String, String> amt1 = new AMT();
        AbstractMap<String, String> amt2 = new AMT();
        assertTrue("assert 0", amt1.equals(amt2));
        assertTrue("assert 1", amt1.equals(amt1));
        assertTrue("assert 2", amt2.equals(amt1));
        amt1.put("1", "one");
        assertFalse("assert 3", amt1.equals(amt2));
        amt1.put("2", "two");
        amt1.put("3", "three");
 
        amt2.put("1", "one");
        amt2.put("2", "two");
        amt2.put("3", "three");
        assertTrue("assert 4", amt1.equals(amt2));
        assertFalse("assert 5", amt1.equals(this));
    } 
 

5
CodeRank
This code example shows how to use the following methods:put
    assertLength(0, types); 
  } 
 
  public void test_setNamedParameterTypes() { 
    FunctionTypeImpl type = new FunctionTypeImpl(new FunctionElementImpl(identifier("f"))); 
    LinkedHashMap<String, Type> expectedTypes = new LinkedHashMap<String, Type>(); 
    expectedTypes.put("a", new InterfaceTypeImpl(new ClassElementImpl(identifier("C")))); 
    type.setNamedParameterTypes(expectedTypes); 
    Map<String, Type> types = type.getNamedParameterTypes(); 
    assertEquals(expectedTypes, types); 
  } 
 
  public void test_setNormalParameterTypes() { 
    FunctionTypeImpl type = new FunctionTypeImpl(new FunctionElementImpl(identifier("f"))); 
    Type[] expectedTypes = new Type[] {new InterfaceTypeImpl(new ClassElementImpl(identifier("C")))}; 
    type.setNormalParameterTypes(expectedTypes); 
    Type[] types = type.getNormalParameterTypes(); 
    assertEquals(expectedTypes, types); 
  } 
 
5
CodeRank
This code example shows how to use the following methods:put, get
 
    /** 
     * @see prefuse.data.search.SearchTupleSet#index(prefuse.data.Tuple, java.lang.String) 
     */ 
    public void index(Tuple t, String field) {
        TupleSet ts = (TupleSet)m_source.get(field);
        if ( ts == null ) {
            ts = new DefaultTupleSet();
            m_source.put(field, ts);
        } 
        ts.addTuple(t);
    } 
 
    /** 
     * @see prefuse.data.search.SearchTupleSet#unindex(prefuse.data.Tuple, java.lang.String) 
     */ 
    public void unindex(Tuple t, String field) {
        TupleSet ts = (TupleSet)m_source.get(field);
        if ( ts != null ) {
            ts.removeTuple(t);
6
CodeRank
put Method Overview
Associates the specified value with the specified key in this map (optional operation).
See Code Examples for other Java 8 AbstractMap Methods: