@ SuppressWarnings ( "rawtypes" ) @ Override public < T > T asObject ( String string , Class < T > valueType ) throws IllegalArgumentException { if ( string . isEmpty ( ) ) { return null ; } // at this point value type is guaranteed to be enumeration if ( Types . isKindOf ( valueType , OrdinalEnum . class ) ) { return valueType . getEnumConstants ( ) [ Integer . parseInt ( string ) ] ; } return ( T ) Enum . valueOf ( ( Class ) valueType , string ) ; }
Create enumeration constant for given string and enumeration type .