You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is Issue 28 moved from a Google Code project.
Added by 2010-07-15T17:37:39.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Defect, Priority-Medium
Original description
Don't know whether it is generally useful but if you think so, feel free to include:
import com.pietschy.gwt.pectin.client.value.Converter;
/**
* Converts the value of an {@link Enum} type to its {@link Enum#ordinal()} integer.
*
* @param <E>
* the enum type
*/
public class EnumToIntegerConverter<E extends Enum<E>> implements Converter<E, Integer>
{
private final Class<E> clazz;
public EnumToIntegerConverter(Class<E> clazz)
{
this.clazz = clazz;
}
@Override
public E fromSource(Integer value)
{
return clazz.getEnumConstants()[value];
}
@Override
public Integer toSource(E value)
{
return value.ordinal();
}
}
The text was updated successfully, but these errors were encountered:
This is Issue 28 moved from a Google Code project.
Added by 2010-07-15T17:37:39.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Defect, Priority-Medium
Original description
The text was updated successfully, but these errors were encountered: