@ PublicEvolving public < T extends Enum < T > > T getEnum ( final Class < T > enumClass , final ConfigOption < String > configOption ) { checkNotNull ( enumClass , "enumClass must not be null" ) ; checkNotNull ( configOption , "configOption must not be null" ) ; final String configValue = getString ( configOption ) ; try { return Enum . valueOf ( enumClass , configValue . toUpperCase ( Locale . ROOT ) ) ; } catch ( final IllegalArgumentException | NullPointerException e ) { final String errorMessage = String . format ( "Value for config option %s must be one of %s (was %s)" , configOption . key ( ) , Arrays . toString ( enumClass . getEnumConstants ( ) ) , configValue ) ; throw new IllegalArgumentException ( errorMessage , e ) ; } }
Returns the value associated with the given config option as an enum .