On Mon, Apr 27, 2020 at 12:28 AM Xeno Amess <xenoam...@gmail.com> wrote:
> I really think we shall have a common template for Enums > Please expand, I do not understand. Gary > > XenoAmess > > ________________________________ > From: Gary Gregory <garydgreg...@gmail.com> > Sent: Monday, April 27, 2020 8:50:22 AM > To: Commons Developers List <dev@commons.apache.org> > Subject: [configuration] > org.apache.commons.configuration2.ImmutableConfiguration.getEnum()? > > Hi All: > > I'd like to have a way to get an enum instance out of > a org.apache.commons.configuration2.ImmutableConfiguration. > > I'm surprised there is nothing like a getEnum(...). Any thoughts about > adding: > > default <T extends Enum<T>> T getEnum(String key, Class<T> enumType) { > return Enum.valueOf(enumType, getString(key)); > } > > default <T extends Enum<T>> T getEnum(String key, Class<T> enumType, String > defaultEnum) { > return Enum.valueOf(enumType, getString(key, defaultEnum)); > } > > ? > Gary >