Other |
---|
tbdUnresolved |
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Every enum type provides a values() method that returns an array of the enum constants. Since arrays are mutable, the returned array must be a freshly created copy of the internal array. It would be nice to have an API that returned an object that represented the enum constants, but avoided having to make a copy of the array just for defensive purposes. For some enum type E this could be something like Stream<E> or perhaps List<E>, with the latter having properties of being random-access and immutable. Something to consider is having two "flavors" or this method, one on the enum type itself, and another on java.lang.Enum or java.lang.Class that would provide the values for an enum given its class. This is similar to the situation with values(), which occurs directly on the enum type, and which has an equivalent java.lang.Class.getEnumConstants().
|