Examples of EnumMap


Examples of com.google.web.bindery.autobean.shared.impl.EnumMap

    assertNotNull(decodedBean.as().getList());
    assertTrue(decodedBean.as().getList().isEmpty());
  }

  public void testEnum() {
    EnumMap map = (EnumMap) f;
    assertEquals("BAR", map.getToken(MyEnum.BAR));
    assertEquals("quux", map.getToken(MyEnum.BAZ));
    assertEquals(MyEnum.BAR, map.getEnum(MyEnum.class, "BAR"));
    assertEquals(MyEnum.BAZ, map.getEnum(MyEnum.class, "quux"));

    List<MyEnum> arrayValue = Arrays.asList(MyEnum.FOO, MyEnum.BAR, null, MyEnum.BAZ);
    Map<MyEnum, Integer> mapValue = new HashMap<MyEnum, Integer>();
    mapValue.put(MyEnum.FOO, 0);
    mapValue.put(MyEnum.BAR, 1);
View Full Code Here

Examples of com.google.web.bindery.autobean.shared.impl.EnumMap

  /**
   * Ensures that enum types that are reachable only through a method
   * parameterization are included in the enum map.
   */
  public void testEnumReachableOnlyThroughParameterization() {
    EnumMap map = (EnumMap) f;
    assertEquals("FOO_LIST", map.getToken(EnumReachableThroughList.FOO_LIST));
    assertEquals("FOO_KEY", map.getToken(EnumReachableThroughMapKey.FOO_KEY));
    assertEquals("FOO_VALUE", map.getToken(EnumReachableThroughMapValue.FOO_VALUE));
    assertEquals(EnumReachableThroughList.FOO_LIST, map.getEnum(EnumReachableThroughList.class,
        "FOO_LIST"));
    assertEquals(EnumReachableThroughMapKey.FOO_KEY, map.getEnum(EnumReachableThroughMapKey.class,
        "FOO_KEY"));
    assertEquals(EnumReachableThroughMapValue.FOO_VALUE, map.getEnum(
        EnumReachableThroughMapValue.class, "FOO_VALUE"));
  }
View Full Code Here

Examples of java.util.EnumMap

  public static Map<Object, Object> createMap(Class<?> mapType, Class<?> keyType, int size) {

    Assert.notNull(mapType, "Map type must not be null!");

    if (EnumMap.class.isAssignableFrom(mapType)) {
      return new EnumMap(asEnumType(keyType));
    }

    return org.springframework.core.CollectionFactory.createMap(mapType, size);
  }
View Full Code Here

Examples of java.util.EnumMap

                        case ID_CC_ENUM_MAP: {
                            int idx = instanceCache.size();
                            instanceCache.add(null);
                            final ClassDescriptor nestedDescriptor = doReadClassDescriptor(readUnsignedByte());
                            final Class<? extends Enum> elementType = nestedDescriptor.getType().asSubclass(Enum.class);
                            return replace(readMapData(unshared, idx, len, new EnumMap(elementType)));
                        }
                        case ID_CC_NCOPIES: {
                            final int idx = instanceCache.size();
                            instanceCache.add(null);
                            final Object obj = Collections.nCopies(len, doReadNestedObject(false, "n-copies member object"));
View Full Code Here

Examples of java.util.EnumMap

        if (attributeName == null) {
            throw new ConversionException("No EnumType specified for EnumMap");
        }
        final Class<?> type = mapper().realClass(reader.getAttribute(attributeName));
        @SuppressWarnings({"rawtypes", "unchecked"})
        final EnumMap<?, ?> map = new EnumMap(type);
        populateMap(reader, context, map);
        return map;
    }
View Full Code Here

Examples of java.util.EnumMap

        super.marshal(source, writer, context);
    }

    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
        Class type = mapper().realClass(reader.getAttribute(mapper().aliasForAttribute("enum-type")));
        EnumMap map = new EnumMap(type);
        populateMap(reader, context, map);
        return map;
    }
View Full Code Here

Examples of java.util.EnumMap

  // This is legit because enumKeyType above is both an enum type (checked at
  // runtime in the EnumMap ctor) and is the type of a subclass of K.
  @SuppressWarnings({ "rawtypes", "unchecked" })
  private static <K, V>
  Map<K, V> makeEnumMap(Class<? extends Enum> t) { return new EnumMap(t); }
View Full Code Here

Examples of java.util.EnumMap

        String attributeName = mapper().aliasForSystemAttribute("enum-type");
        if (attributeName == null) {
            throw new ConversionException("No EnumType specified for EnumMap");
        }
        Class type = mapper().realClass(reader.getAttribute(attributeName));
        EnumMap map = new EnumMap(type);
        populateMap(reader, context, map);
        return map;
    }
View Full Code Here

Examples of java.util.EnumMap

        checkNotNull(entry.getKey());
        checkNotNull(entry.getValue());
      }
      @SuppressWarnings("unchecked")
      // immutable collections are safe for covariant casts
      ImmutableMap<K, V> result = ImmutableEnumMap.asImmutable(new EnumMap(enumMap));
      return result;
    }

    int size = map.size();
    switch (size) {
View Full Code Here

Examples of java.util.EnumMap

        checkNotNull(entry.getKey());
        checkNotNull(entry.getValue());
      }
      @SuppressWarnings("unchecked")
      // immutable collections are safe for covariant casts
      ImmutableMap<K, V> result = ImmutableEnumMap.asImmutable(new EnumMap(enumMap));
      return result;
    }

    @SuppressWarnings("unchecked") // we won't write to this array
    Entry<K, V>[] entries = map.entrySet().toArray(new Entry[0]);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.