Class EnumUtils

java.lang.Object
com.linkedin.venice.utils.EnumUtils

public class EnumUtils extends Object
  • Constructor Details

    • EnumUtils

      public EnumUtils()
  • Method Details

    • getEnumValuesList

      public static <V extends VeniceEnumValue> List<V> getEnumValuesList(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 via valueOf(List, int, Class)
    • getEnumValuesSparseList

      public static <V extends VeniceEnumValue> Map<Integer,V> getEnumValuesSparseList(Class<V> enumToProvideArrayOf)
      This is a relaxed version of getEnumValuesList(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)