-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
9
-
generic
-
generic
A DESCRIPTION OF THE REQUEST :
1. Add a stream() method to java.lang.Enum. This will simplify dealing with enum values, instead of calling values() which returns an array.
2. Add an overload of method of() to EnumSet that uses a predicate to determine the elements in the set;
public static <E extends Enum<E>> Set<E> of(final Predicate<E> aPredicate).
JUSTIFICATION :
Not necessary but would simplify functional programming using enums:
1. Enum.stream()
Currently have to obtain a stream indirectly, e.g:
(a) call values() to get an array of enum values, convert the array to a List, call stream() on the List.
or
(b) call EnumSet.allOf(elementType) to get an EnumSet of the values and call stream on the EnumSet.
2. EnumSet.of(Predicate<E>)
The current of() methods select by element identity. EnumSet.of(Predicate<E>) would select elements by their properties.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Not applicable
ACTUAL -
Not applicable
---------- BEGIN SOURCE ----------
Not applicable
---------- END SOURCE ----------
1. Add a stream() method to java.lang.Enum. This will simplify dealing with enum values, instead of calling values() which returns an array.
2. Add an overload of method of() to EnumSet that uses a predicate to determine the elements in the set;
public static <E extends Enum<E>> Set<E> of(final Predicate<E> aPredicate).
JUSTIFICATION :
Not necessary but would simplify functional programming using enums:
1. Enum.stream()
Currently have to obtain a stream indirectly, e.g:
(a) call values() to get an array of enum values, convert the array to a List, call stream() on the List.
or
(b) call EnumSet.allOf(elementType) to get an EnumSet of the values and call stream on the EnumSet.
2. EnumSet.of(Predicate<E>)
The current of() methods select by element identity. EnumSet.of(Predicate<E>) would select elements by their properties.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Not applicable
ACTUAL -
Not applicable
---------- BEGIN SOURCE ----------
Not applicable
---------- END SOURCE ----------
- duplicates
-
JDK-8073381 need API to get enum's values without creating a new array
-
- Open
-