Package com.github.twitch4j.util
Class EnumUtil
java.lang.Object
com.github.twitch4j.util.EnumUtil
-
Method Summary
Modifier and TypeMethodDescriptionbuildMapping
(@NotNull E[] values) Creates a mapping of enum values by their string representation.buildMapping
(@NotNull E[] values, @NotNull Function<E, K> keySelector) Creates a mapping of enum values via an arbitrary key derivation function.buildMapping
(@NotNull E[] values, @NotNull Function<E, K> keySelector, @NotNull Function<E, V> valueMapper) Transforms enum values to a key-value map based on the specified functions.
-
Method Details
-
buildMapping
public static <E extends Enum<E>,K, Map<K,V> V> buildMapping(@NotNull @NotNull E[] values, @NotNull @NotNull Function<E, K> keySelector, @NotNull @NotNull Function<E, V> valueMapper) Transforms enum values to a key-value map based on the specified functions.- Type Parameters:
E
- the type of enumK
- the type of keysV
- the type of values- Parameters:
values
- the values within an enum to be transformedkeySelector
- a function that derives a key associated to an enum entryvalueMapper
- a function that yields a value for a given enum entry- Returns:
- a
Map
of key-value associations from transforming the specified enum entries
-
buildMapping
public static <E extends Enum<E>,K> Map<K,E> buildMapping(@NotNull @NotNull E[] values, @NotNull @NotNull Function<E, K> keySelector) Creates a mapping of enum values via an arbitrary key derivation function.- Type Parameters:
E
- the type of enumK
- the type of keys- Parameters:
values
- the values within an enum to be mappedkeySelector
- a function that derives a key associated to an enum value- Returns:
- the mapping of enum values by the derived keys
- See Also:
-
buildMapping
Creates a mapping of enum values by their string representation.- Type Parameters:
E
- the type of enum- Parameters:
values
- the values within an enum to be mapped- Returns:
- a mapping of
Enum.toString()
to the enum value itself - See Also:
-