Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-789

Add ImmutableConfiguration.getEnum() methods

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.8.0
    • Type conversion
    • None

    Description

      Add ImmutableConfiguration.getEnum methods:

      • org.apache.commons.configuration2.ImmutableConfiguration.getEnum(String, Class<T>)
      • org.apache.commons.configuration2.ImmutableConfiguration.getEnum(String, Class<T>, T)
        /**
         * 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)
        

        and

        /**
         * 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) 
        

      Attachments

        Activity

          People

            ggregory Gary D. Gregory
            ggregory Gary D. Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: