Class EnumUtils

java.lang.Object
io.jmix.core.metamodel.datatype.impl.EnumUtils

public class EnumUtils extends Object
A helper class to be used in EnumClass implementations to convert identifiers to enum values.
  • Constructor Details

    • EnumUtils

      public EnumUtils()
  • Method Details

    • fromId

      @Nullable public static <T extends Enum<T> & EnumClass<V>, V> T fromId(Class<T> e, V id)
      Returns an enum value for the given id.
      Parameters:
      e - enum class
      id - id
      Returns:
      enum value or null if the passed id is null
      Throws:
      IllegalArgumentException - if there are no enum values with the given id
    • fromId

      public static <T extends Enum<T> & EnumClass<V>, V> T fromId(Class<T> e, V id, T defaultValue)
      Returns an enum value for the given id.
      Parameters:
      e - enum class
      id - id
      defaultValue - the value to return if null is passed as id
      Returns:
      enum value
      Throws:
      IllegalArgumentException - if there are no enum values with the given id
    • fromIdSafe

      public static <T extends Enum<T> & EnumClass<V>, V> T fromIdSafe(Class<T> e, V id, T defaultValue)
      Returns an enum value for the given id, or the default value if null is passed or there are no enum values with the given id.
      Parameters:
      e - enum class
      id - id
      defaultValue - the value to return if null is passed as id or if there are no enum values with the given id
      Returns:
      enum value