New issue report by gk5885:
Effective Java's 'Item 33: Use EnumMap instead of ordinal indexing'
suggests the use of EnumMap for associating data with enums.
Often times the data in such maps doesn't change and in the spirit
of 'Item 15: Minimize mutability', an ImmutableEnumMap would
be ideal.
To go with an ImmutableEnumMap, an ImmutableEnumMap.Builder like
ImmutableMap.Builder would be great.
Finally, it is often the case that you want to ensure that there is a
value associated with every value in an enum. A builder that
ensures that all enum values are keys would be useful because in the
following example, if you intend to have a Bar associated with
every value of Foo, the exhaustive builder would always fail at 1 while
the standard builder would only fail at two with values of
someFooEnum that are not keys in the map.
ImmutableEnumMap<FooEnum, Bar> enumMap =
ImmutableEnumMap.exhaustiveBuilder().put(foo1, bar1)...build(); //1
...
Bar value = checkNotNull(enumMap.get(someFooEnum)); //2
Issue attributes:
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings