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
}
}
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);
}
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;
}
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);
}
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));
}
Aggregations