Search in sources :

Example 21 with EnumMap

use of java.util.EnumMap in project robovm by robovm.

the class EnumMapTest method test_ConstructorLjava_util_EnumMap.

/**
     * java.util.EnumMap#EnumMap(EnumMap)
     */
@SuppressWarnings({ "unchecked", "boxing" })
public void test_ConstructorLjava_util_EnumMap() {
    EnumMap enumMap;
    EnumMap enumColorMap = null;
    try {
        enumMap = new EnumMap(enumColorMap);
        fail("Expected NullPointerException");
    } catch (NullPointerException e) {
    // Expected
    }
    enumColorMap = new EnumMap<Color, Double>(Color.class);
    Double double1 = new Double(1);
    enumColorMap.put(Color.Green, 2);
    enumColorMap.put(Color.Blue, double1);
    enumMap = new EnumMap(enumColorMap);
    assertEquals("Constructor fails", 2, enumMap.get(Color.Green));
    assertSame("Constructor fails", double1, enumMap.get(Color.Blue));
    assertNull("Constructor fails", enumMap.get(Color.Red));
    enumMap.put(Color.Red, 1);
    assertEquals("Wrong value", 1, enumMap.get(Color.Red));
    try {
        enumMap.put(Size.Middle, 2);
        fail("Expected ClassCastException");
    } catch (ClassCastException e) {
    // Expected
    }
}
Also used : EnumMap(java.util.EnumMap)

Example 22 with EnumMap

use of java.util.EnumMap in project robovm by robovm.

the class EnumMapTest method testSerializationCompatibility.

/**
     * serialization/deserialization compatibility with RI.
     */
@SuppressWarnings({ "unchecked", "boxing" })
public void testSerializationCompatibility() throws Exception {
    EnumMap enumColorMap = new EnumMap<Color, Double>(Color.class);
    enumColorMap.put(Color.Red, 1);
    enumColorMap.put(Color.Blue, 3);
    SerializationTest.verifyGolden(this, enumColorMap);
}
Also used : EnumMap(java.util.EnumMap)

Example 23 with EnumMap

use of java.util.EnumMap in project es6draft by anba.

the class ReflectParser method toBuilderMap.

private static EnumMap<Type, Callable> toBuilderMap(ExecutionContext cx, ScriptObject builderObject) {
    EnumMap<Type, Callable> map = new EnumMap<>(Type.class);
    for (Type builder : Type.values()) {
        String methodName = builder.name;
        if (methodName == null) {
            continue;
        }
        if (!HasProperty(cx, builderObject, methodName)) {
            continue;
        }
        Callable method = GetMethod(cx, builderObject, methodName);
        if (method == null) {
            continue;
        }
        map.put(builder, method);
    }
    return map;
}
Also used : EnumMap(java.util.EnumMap) Callable(com.github.anba.es6draft.runtime.types.Callable)

Example 24 with EnumMap

use of java.util.EnumMap in project es6draft by anba.

the class Properties method createExternalAccessors.

private static <OWNER> void createExternalAccessors(ExecutionContext cx, ScriptObject target, OWNER owner, ObjectLayout layout, Converter converter) {
    LinkedHashMap<String, PropertyDescriptor> stringProps = new LinkedHashMap<>();
    EnumMap<BuiltinSymbol, PropertyDescriptor> symbolProps = new EnumMap<>(BuiltinSymbol.class);
    for (Entry<Accessor, MethodHandle> entry : layout.accessors.entrySet()) {
        MethodHandle handle = getInstanceMethodHandle(cx, converter, entry.getValue(), owner);
        createExternalAccessor(cx, entry.getKey(), handle, stringProps, symbolProps);
    }
    defineProperties(cx, target, stringProps, symbolProps);
}
Also used : BuiltinSymbol(com.github.anba.es6draft.runtime.types.BuiltinSymbol) PropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor) AccessorPropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor.AccessorPropertyDescriptor) EnumMap(java.util.EnumMap) LinkedHashMap(java.util.LinkedHashMap) MethodHandle(java.lang.invoke.MethodHandle)

Example 25 with EnumMap

use of java.util.EnumMap in project cassandra by apache.

the class CloudstackSnitchTest method testRacks.

@Test
public void testRacks() throws IOException, ConfigurationException {
    az = "ch-gva-1";
    CloudstackSnitch snitch = new TestCloudstackSnitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");
    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState, VersionedValue> stateMap = new EnumMap<>(ApplicationState.class);
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("ch-zrh"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.rack("2"));
    Gossiper.instance.getEndpointStateForEndpoint(nonlocal).addApplicationStates(stateMap);
    assertEquals("ch-zrh", snitch.getDatacenter(nonlocal));
    assertEquals("2", snitch.getRack(nonlocal));
    assertEquals("ch-gva", snitch.getDatacenter(local));
    assertEquals("1", snitch.getRack(local));
}
Also used : VersionedValue(org.apache.cassandra.gms.VersionedValue) ApplicationState(org.apache.cassandra.gms.ApplicationState) InetAddress(java.net.InetAddress) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Aggregations

EnumMap (java.util.EnumMap)146 Map (java.util.Map)27 Collection (java.util.Collection)22 HashMap (java.util.HashMap)22 ArrayList (java.util.ArrayList)19 DecodeHintType (com.google.zxing.DecodeHintType)17 Test (org.junit.Test)16 IOException (java.io.IOException)12 List (java.util.List)10 Set (java.util.Set)10 Occur (org.apache.lucene.search.BooleanClause.Occur)10 EncodeHintType (com.google.zxing.EncodeHintType)8 BitMatrix (com.google.zxing.common.BitMatrix)8 Iterator (java.util.Iterator)7 NoSuchElementException (java.util.NoSuchElementException)6 TreeMap (java.util.TreeMap)6 Bundle (android.os.Bundle)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 URL (java.net.URL)5 SortedMap (java.util.SortedMap)5