Class EnumUtils


  • public class EnumUtils
    extends java.lang.Object
    Helpers for the EnumeratedAttributes wrapping enums in this package.
    • Constructor Summary

      Constructors 
      Constructor Description
      EnumUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <E extends java.lang.Enum<E>>
      E
      valueOf​(java.lang.Class<E> clazz, java.lang.String value, java.util.function.Function<E,​java.lang.String> alternativeProvider)
      Maps a string to an enum value.
      static <E extends java.lang.Enum<E>>
      java.lang.String[]
      valuesPlus​(java.lang.Class<E> clazz, java.util.function.Function<E,​java.lang.String> alternativeProvider)
      Provides strings that can be mapped to enum values unambiguously.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EnumUtils

        public EnumUtils()
    • Method Detail

      • valuesPlus

        public static <E extends java.lang.Enum<E>> java.lang.String[] valuesPlus​(java.lang.Class<E> clazz,
                                                                                  java.util.function.Function<E,​java.lang.String> alternativeProvider)
        Provides strings that can be mapped to enum values unambiguously.
        Type Parameters:
        E - the enum type
        Parameters:
        clazz - the enum type
        alternativeProvider - a function generating alternative names for the enum constant
        Returns:
        array of enum constants and alternative names for each constant.
      • valueOf

        public static <E extends java.lang.Enum<E>> E valueOf​(java.lang.Class<E> clazz,
                                                              java.lang.String value,
                                                              java.util.function.Function<E,​java.lang.String> alternativeProvider)
                                                       throws org.apache.tools.ant.BuildException
        Maps a string to an enum value.
        Type Parameters:
        E - the enum type
        Parameters:
        clazz - the enum type
        value - the string to translate
        alternativeProvider - a function generating alternative names for the enum constant
        Returns:
        the enum constant the string could be mapped to
        Throws:
        java.lang.NullPointerException - if value is null
        org.apache.tools.ant.BuildException - if value can not be translated