Class EnumConstants


  • public final class EnumConstants
    extends Object
    Resolves an enum's constants by ordinal and by name.
    • Method Detail

      • nameByOrdinal

        public static String nameByOrdinal​(ClassPool pool,
                                           String enumInternalName,
                                           int ordinal)
        Looks up the enum constant declared at a given position.
        Parameters:
        pool - the class pool to resolve the enum from, may be null to force the reflection path
        enumInternalName - the enum class, in dotted or internal form
        ordinal - the declaration position
        Returns:
        the constant name, or null if the enum could not be resolved or the ordinal is out of range
      • ordinalByName

        public static Integer ordinalByName​(ClassPool pool,
                                            String enumInternalName,
                                            String constantName)
        Looks up the declaration position of a named enum constant.
        Parameters:
        pool - the class pool to resolve the enum from, may be null to force the reflection path
        enumInternalName - the enum class, in dotted or internal form
        constantName - the constant to find
        Returns:
        the ordinal, or null if the enum or the constant could not be resolved