In Spring framework, the LenientToEnumConverter class in LenientObjectToEnumConverterFactory.java provides a neat way to return an enum object based on its String key. For example, spring security uses this method to retrieve the CommonOAuth2Provider enum using a String input. The Enum.valueOf(this.enumType, value); finds the enum object where the name matches exactly with the source. If the result is not found, then the findEnum(value) will compare canonical value of the source and canonical values of enum names to find the match.