public class EnumConverter<E extends Enum> extends Object implements NuitonConverter<E>
Enum type-safe (exact type is enumType
from and to String.
It is possible also to convert the enum object from his ordinal using method convertFromOrdinal(Class, Object).
you can also define a default value while trying to convert null value.
To register a new such converter use methods ConverterUtil.registerEnumConverter(Class),
or ConverterUtil.registerEnumConverter(Class, Object) .
Enum,
Enum.ordinal()| Modifier and Type | Field and Description |
|---|---|
protected Object |
defaultValue
Default value to use if try to convert
null value and flag useDefault is on. |
protected Class<E> |
enumType
Enum type-safe.
|
protected boolean |
useDefault
flag to use or not default value.
|
| Constructor and Description |
|---|
EnumConverter(Class<E> enumType) |
EnumConverter(Class<E> enumType,
Object defaultValue) |
| Modifier and Type | Method and Description |
|---|---|
protected EnumSet<?> |
allOf(Class<?> aClass) |
<T> T |
convert(Class<T> aClass,
Object value) |
protected Object |
convertFromOrdinal(Class<?> aClass,
Object value) |
Class<E> |
getType() |
protected static boolean |
isEnabled(Class<?> aClass,
Class<?> enumType) |
protected Object |
valueOf(Class<?> aClass,
Object value) |
protected Object defaultValue
null value and flag useDefault is on.protected boolean useDefault
Copyright © 2014–2018 CodeLutin. All rights reserved.