Package org.eclipse.core.databinding.conversion

# 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 `Enum`s.

Since:
  1.11

## Constructor Summary

Constructors
Constructor
Description
`EnumConverters()`

## Method Summary

Modifier and Type
Method
Description
`static <T extends Enum<T>>
IConverter<Integer,T>`
`fromOrdinal(Class<T> enumToType)`
Creates a converter which converts from `Enum.ordinal`s to enum values of the given type.
`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.
`static <T extends Enum<T>>
IConverter<T,Integer>`
`toOrdinal(Class<T> enumFromType)`
Creates a converter which converts from `Enum.ordinal`s to enum values of the given type.
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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.ordinal`s 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.ordinal`s 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