Class EnumUtils


  • public class EnumUtils
    extends Object
    Several helper methods to convert integer flag (sets) into enum (sets)
    Author:
    Martin Steiger
    • Field Detail

      • UNINITIALIZED

        public static final int UNINITIALIZED
        Uninitialized integer flag
        See Also:
        Constant Field Values
    • Constructor Detail

      • EnumUtils

        public EnumUtils()
    • Method Detail

      • toInteger

        public static <E extends Enum<E>> int toInteger​(E val)
        Parameters:
        val - the enum
        Returns:
        the index of the enum in the enum list
      • fromInteger

        public static <E extends Enum<E>> E fromInteger​(int idx,
                                                        Class<E> clazz)
        Parameters:
        idx - the enum index
        clazz - the enum class
        Returns:
        the enum at position idx
      • setFromInteger

        public static <T extends FlagEnumSet<T> setFromInteger​(int flags,
                                                                 Class<T> clazz)
        Parameters:
        flags - the ORed flags
        clazz - the enum class
        Returns:
        the representing set
      • setToInteger

        public static <T extends FlagEnum> int setToInteger​(Set<T> set)
        Parameters:
        set - the set to convert
        Returns:
        the flags combined into an integer