Package com.linkedin.venice.utils
Class EnumUtils
- java.lang.Object
-
- com.linkedin.venice.utils.EnumUtils
-
public class EnumUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description EnumUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <V extends VeniceEnumValue>
java.util.List<V>getEnumValuesList(java.lang.Class<V> enumToProvideArrayOf)
Lots of defensive coding to ensure that control message type values are: 1.static <V extends VeniceEnumValue>
java.util.Map<java.lang.Integer,V>getEnumValuesSparseList(java.lang.Class<V> enumToProvideArrayOf)
This is a relaxed version ofgetEnumValuesList(Class)
which returns a map instead of a list.static <V extends VeniceEnumValue>
VvalueOf(java.util.List<V> valuesList, int value, java.lang.Class<V> enumClass)
static <V extends VeniceEnumValue>
VvalueOf(java.util.List<V> valuesList, int value, java.lang.Class<V> enumClass, java.util.function.Function<java.lang.String,VeniceException> exceptionConstructor)
static <V extends VeniceEnumValue>
VvalueOf(java.util.Map<java.lang.Integer,V> valuesMap, int value, java.lang.Class<V> enumClass)
static <V extends VeniceEnumValue>
VvalueOf(java.util.Map<java.lang.Integer,V> valuesMap, int value, java.lang.Class<V> enumClass, java.util.function.Function<java.lang.String,VeniceException> exceptionConstructor)
-
-
-
Method Detail
-
getEnumValuesList
public static <V extends VeniceEnumValue> java.util.List<V> getEnumValuesList(java.lang.Class<V> enumToProvideArrayOf)
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> java.util.Map<java.lang.Integer,V> getEnumValuesSparseList(java.lang.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(java.util.List<V> valuesList, int value, java.lang.Class<V> enumClass)
-
valueOf
public static <V extends VeniceEnumValue> V valueOf(java.util.List<V> valuesList, int value, java.lang.Class<V> enumClass, java.util.function.Function<java.lang.String,VeniceException> exceptionConstructor)
-
valueOf
public static <V extends VeniceEnumValue> V valueOf(java.util.Map<java.lang.Integer,V> valuesMap, int value, java.lang.Class<V> enumClass)
-
valueOf
public static <V extends VeniceEnumValue> V valueOf(java.util.Map<java.lang.Integer,V> valuesMap, int value, java.lang.Class<V> enumClass, java.util.function.Function<java.lang.String,VeniceException> exceptionConstructor)
-
-