Relates :
|
|
Relates :
|
|
Relates :
|
The new collections convenience factories (JDK-8048330) make creation of immutable lists, sets, and maps more convenient. This highlights a potential need to enhance EnumMap and EnumSet to bring them into line. There are several issues: a) There are six overloads for EnumSet.of(), with one through five arguments, plus a varargs overload. There are no convenience factories for EnumMap. It might make sense to add convenience factories to match the ones in Set and Map. (Note, though, that EnumSet and EnumMap are mutable.) b) Calling Set.of(EnumClass.ONE, EnumClass.TWO, EnumClass.THREE) will produce a set of reference type instead of an implementation specialized for enum values. c) There are no immutable versions of EnumMap and EnumSet. Note: Guava has Maps.immutableEnumMap() and Sets.immutableEnumSet(), but not any corresponding public types as far as I can see. It's not entirely clear what should be done, but there does seem to be room to explore this space. See discussion at: http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-December/037292.html