You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2020/04/27 13:39:00 UTC
[jira] [Updated] (CONFIGURATION-789) Add
ImmutableConfiguration.getEnum() methods
[ https://issues.apache.org/jira/browse/CONFIGURATION-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory updated CONFIGURATION-789:
------------------------------------------
Summary: Add ImmutableConfiguration.getEnum() methods (was: Add ImmutableConfiguration.getEnum methods)
> Add ImmutableConfiguration.getEnum() methods
> --------------------------------------------
>
> Key: CONFIGURATION-789
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-789
> Project: Commons Configuration
> Issue Type: New Feature
> Components: Type conversion
> Reporter: Gary D. Gregory
> Assignee: Gary D. Gregory
> Priority: Major
>
> Add {{ImmutableConfiguration.getEnum}} methods:
> * org.apache.commons.configuration2.ImmutableConfiguration.getEnum(String, Class<T>)
> * org.apache.commons.configuration2.ImmutableConfiguration.getEnum(String, Class<T>, T)
> {code:java}
> /**
> * Gets an enum associated with the given configuration key.
> *
> * @param <T> The enum type whose constant is to be returned.
> * @param enumType the \{@code Class} object of the enum type from which to return a constant
> * @param key The configuration key.
> * @return The associated enum.
> *
> * @throws org.apache.commons.configuration2.ex.ConversionException is thrown if the key maps to an object that
> * is not a String.
> * @since 2.8
> */
> default <T extends Enum<T>> T getEnum(String key, Class<T> enumType)
> {code}
> and
> {code:java}
> } catch (IllegalArgumentException e) {
> throw new ConversionException(e);
> }
> }
> /**
> * Gets the enum associated with the given configuration key. If the key doesn't map to an existing object, the
> * default value is returned.
> *
> * @param <T> The enum type whose constant is to be returned.
> * @param key The configuration key.
> * @param enumType the \{@code Class} object of the enum type from which to return a constant
> * @param defaultValue The default value.
> * @return The associated enum if key is found and has valid format, default value otherwise.
> *
> * @throws org.apache.commons.configuration2.ex.ConversionException is thrown if the key maps to an object that is
> * not a Enum.
> * @since 2.8
> */
> default <T extends Enum<T>> T getEnum(String key, Class<T> enumType, T defaultValue)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)