Search in sources :

Example 6 with AbstractMap

use of java.util.AbstractMap in project j2objc by google.

the class TreeMapTest method test_clone.

/**
     * @tests java.util.TreeMap#clone()
     */
public void test_clone() {
    // Test for method java.lang.Object java.util.TreeMap.clone()
    TreeMap clonedMap = (TreeMap) tm.clone();
    assertTrue("Cloned map does not equal the original map", clonedMap.equals(tm));
    assertTrue("Cloned map is the same reference as the original map", clonedMap != tm);
    for (Object element : objArray) {
        assertTrue("Cloned map contains incorrect elements", clonedMap.get(element.toString()) == tm.get(element.toString()));
    }
    TreeMap map = new TreeMap();
    map.put("key", "value");
    // get the keySet() and values() on the original Map
    Set keys = map.keySet();
    Collection values = map.values();
    assertEquals("values() does not work", "value", values.iterator().next());
    assertEquals("keySet() does not work", "key", keys.iterator().next());
    AbstractMap map2 = (AbstractMap) map.clone();
    map2.put("key", "value2");
    Collection values2 = map2.values();
    assertTrue("values() is identical", values2 != values);
    // values() and keySet() on the cloned() map should be different
    assertEquals("values() was not cloned", "value2", values2.iterator().next());
    map2.clear();
    map2.put("key2", "value3");
    Set key2 = map2.keySet();
    assertTrue("keySet() is identical", key2 != keys);
    assertEquals("keySet() was not cloned", "key2", key2.iterator().next());
}
Also used : AbstractMap(java.util.AbstractMap) Set(java.util.Set) Collection(java.util.Collection) TreeMap(java.util.TreeMap)

Example 7 with AbstractMap

use of java.util.AbstractMap in project j2objc by google.

the class LinkedHashMapTest method test_clone.

/**
     * java.util.LinkedHashMap#clone()
     */
public void test_clone() {
    // Test for method java.lang.Object java.util.LinkedHashMap.clone()
    LinkedHashMap hm2 = (LinkedHashMap) hm.clone();
    assertTrue("Clone answered equivalent LinkedHashMap", hm2 != hm);
    for (int counter = 0; counter < hmSize; counter++) assertTrue("Clone answered unequal LinkedHashMap", hm.get(objArray2[counter]) == hm2.get(objArray2[counter]));
    LinkedHashMap map = new LinkedHashMap();
    map.put("key", "value");
    // get the keySet() and values() on the original Map
    Set keys = map.keySet();
    Collection values = map.values();
    assertEquals("values() does not work", "value", values.iterator().next());
    assertEquals("keySet() does not work", "key", keys.iterator().next());
    AbstractMap map2 = (AbstractMap) map.clone();
    map2.put("key", "value2");
    Collection values2 = map2.values();
    assertTrue("values() is identical", values2 != values);
    // values() and keySet() on the cloned() map should be different
    assertEquals("values() was not cloned", "value2", values2.iterator().next());
    map2.clear();
    map2.put("key2", "value3");
    Set key2 = map2.keySet();
    assertTrue("keySet() is identical", key2 != keys);
    assertEquals("keySet() was not cloned", "key2", key2.iterator().next());
}
Also used : AbstractMap(java.util.AbstractMap) Set(java.util.Set) Collection(java.util.Collection) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with AbstractMap

use of java.util.AbstractMap in project j2objc by google.

the class AbstractMapTest method test_containValue.

/**
     * @tests java.util.AbstractMap#containsValue(Object)
     */
public void test_containValue() {
    AbstractMap map = new AMT();
    assertFalse(map.containsValue("v"));
    assertFalse(map.containsValue(null));
    map.put("k", "v");
    map.put("key", null);
    map.put(null, "value");
    assertTrue(map.containsValue("v"));
    assertTrue(map.containsValue("value"));
    assertTrue(map.containsValue(null));
}
Also used : AbstractMap(java.util.AbstractMap)

Example 9 with AbstractMap

use of java.util.AbstractMap in project j2objc by google.

the class AbstractMapTest method test_get.

/**
     * @tests java.util.AbstractMap#get(Object)
     */
public void test_get() {
    AbstractMap map = new AMT();
    assertNull(map.get("key"));
    assertNull(map.get(null));
    map.put("k", "v");
    map.put("key", null);
    map.put(null, "value");
    assertEquals("v", map.get("k"));
    assertNull(map.get("key"));
    assertEquals("value", map.get(null));
}
Also used : AbstractMap(java.util.AbstractMap)

Example 10 with AbstractMap

use of java.util.AbstractMap in project lucene-solr by apache.

the class SpatialDocMaker method makeSpatialStrategy.

/**
   * Builds a SpatialStrategy from configuration options.
   */
protected SpatialStrategy makeSpatialStrategy(final Config config) {
    //A Map view of Config that prefixes keys with "spatial."
    Map<String, String> configMap = new AbstractMap<String, String>() {

        @Override
        public Set<Entry<String, String>> entrySet() {
            throw new UnsupportedOperationException();
        }

        @Override
        public String get(Object key) {
            return config.get("spatial." + key, null);
        }
    };
    SpatialContext ctx = SpatialContextFactory.makeSpatialContext(configMap, null);
    return makeSpatialStrategy(config, configMap, ctx);
}
Also used : AbstractMap(java.util.AbstractMap) SpatialContext(org.locationtech.spatial4j.context.SpatialContext)

Aggregations

AbstractMap (java.util.AbstractMap)23 LinkedHashMap (java.util.LinkedHashMap)14 HashMap (java.util.HashMap)13 IdentityHashMap (java.util.IdentityHashMap)13 TreeMap (java.util.TreeMap)12 Map (java.util.Map)8 WeakHashMap (java.util.WeakHashMap)8 Collection (java.util.Collection)5 Set (java.util.Set)5 Comparator (java.util.Comparator)3 Decorator (javax.enterprise.inject.spi.Decorator)1 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 Analyzer (org.apache.lucene.analysis.Analyzer)1 IndexSettings (org.elasticsearch.index.IndexSettings)1 IndexAnalyzers (org.elasticsearch.index.analysis.IndexAnalyzers)1 NamedAnalyzer (org.elasticsearch.index.analysis.NamedAnalyzer)1 MapperService (org.elasticsearch.index.mapper.MapperService)1 SimilarityService (org.elasticsearch.index.similarity.SimilarityService)1 CurrentInjectionPoint (org.jboss.weld.injection.CurrentInjectionPoint)1 EmptyInjectionPoint (org.jboss.weld.injection.EmptyInjectionPoint)1