Package com.linkedin.venice.utils
Class EnumUtils
java.lang.Object
com.linkedin.venice.utils.EnumUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V extends VeniceEnumValue>
List<V>getEnumValuesList
(Class<V> enumToProvideArrayOf) Lots of defensive coding to ensure that control message type values are: 1.static <V extends VeniceEnumValue>
Map<Integer,V> getEnumValuesSparseList
(Class<V> enumToProvideArrayOf) This is a relaxed version ofgetEnumValuesList(Class)
which returns a map instead of a list.static <V extends VeniceEnumValue>
Vstatic <V extends VeniceEnumValue>
VvalueOf
(List<V> valuesList, int value, Class<V> enumClass, Function<String, VeniceException> exceptionConstructor) static <V extends VeniceEnumValue>
Vstatic <V extends VeniceEnumValue>
VvalueOf
(Map<Integer, V> valuesMap, int value, Class<V> enumClass, Function<String, VeniceException> exceptionConstructor)
-
Constructor Details
-
EnumUtils
public EnumUtils()
-
-
Method Details
-
getEnumValuesList
Lots of defensive coding to ensure that control message type values are: 1. Unique 2. From 0 to N 3. Without gaps Checking these assumptions here helps to simplify valueOf(int) as much as possible, which is valuable since it's a hot path call. If these assumptions change (e.g. if we deprecate some message types such that there are gaps, then we may need to relax some constraints here and increase checks in valueOf(int) instead. The list returned by this utility function should: - be stored statically - be accessed viavalueOf(List, int, Class)
-
getEnumValuesSparseList
public static <V extends VeniceEnumValue> Map<Integer,V> getEnumValuesSparseList(Class<V> enumToProvideArrayOf) This is a relaxed version ofgetEnumValuesList(Class)
which returns a map instead of a list. This is useful when the values are not contiguous, or when the values are not starting from 0. -
valueOf
public static <V extends VeniceEnumValue> V valueOf(List<V> valuesList, int value, Class<V> enumClass) -
valueOf
public static <V extends VeniceEnumValue> V valueOf(List<V> valuesList, int value, Class<V> enumClass, Function<String, VeniceException> exceptionConstructor) -
valueOf
public static <V extends VeniceEnumValue> V valueOf(Map<Integer, V> valuesMap, int value, Class<V> enumClass) -
valueOf
public static <V extends VeniceEnumValue> V valueOf(Map<Integer, V> valuesMap, int value, Class<V> enumClass, Function<String, VeniceException> exceptionConstructor)
-