Class EnumConverters

java.lang.Object
org.eclipse.core.databinding.conversion.EnumConverters

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

    • EnumConverters

      public EnumConverters()
  • Method Details

    • 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