Class EnumConverters


  • public class EnumConverters
    extends Object
    Contains static methods the create converters for working with Enums.
    Since:
    1.11
    • Constructor Detail

      • EnumConverters

        public EnumConverters()
    • Method Detail

      • fromOrdinal

        public static <T extends Enum<T>> IConverter<Integer,​T> fromOrdinal​(Class<T> enumToType)
        Creates a converter which converts from Enum.ordinals to enum values of the given type. Invalid ordinal values are converted to null.
        Parameters:
        enumToType - to type; not null
        Returns:
        the created converter
      • fromString

        public static <T extends Enum<T>> IConverter<String,​T> fromString​(Class<T> enumToType)
        Creates a converter which converts from the toString(java.lang.Class<T>) values of enums values to enum values themselves. Invalid string values are converted to null.
        Parameters:
        enumToType - to type; not null
        Returns:
        the created converter
      • toOrdinal

        public static <T extends Enum<T>> IConverter<T,​Integer> toOrdinal​(Class<T> enumFromType)
        Creates a converter which converts from Enum.ordinals to enum values of the given type. null in the converter input is converted to null.
        Parameters:
        enumFromType - from type; not null
        Returns:
        the created converter
      • toString

        public static <T extends Enum<T>> IConverter<T,​String> toString​(Class<T> enumFromType)
        Creates a converter which converts to the toString(java.lang.Class<T>) values of the enum constants. null in the converter input is converted to null.
        Parameters:
        enumFromType - from type; not null
        Returns:
        the created converter