Class EnumUtil
formatEnumNameAsCapitalized: MY_ENUM_VALUE -> My enum value
formatEnumNameAsTitleCase: MY_ENUM_VALUE -> My Enum Value
formatEnumNameAsSpacedWords: MY_ENUM_VALUE -> MY ENUM VALUE
convertToStyleClassName: MY_ENUM_VALUE -> my-enum-value
-
Method Summary
Modifier and TypeMethodDescriptionconvertAllToStylesClassName(Class<T> enumClass) convertAllToStylesClassName(T[] enumValues) convertToStyleClassName(T enumValue) Converts the enum name to a lower case string, replacing underscores with hyphens, suitable for use as a CSS class name.formatEnumNameAsCapitalized(String enumName) Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase.formatEnumNameAsCapitalized(T enumValue) Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase.formatEnumNameAsCapitalized(T enumValue, String nullDefaultValue) Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase.formatEnumNameAsSpacedWords(String enumName) Replaces underscores in the string representation of an enum name with spaces.formatEnumNameAsSpacedWords(T enumValue) Replaces underscores in the string representation of an enum name with spaces.formatEnumNameAsTitleCase(String enumName) Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word.formatEnumNameAsTitleCase(String enumName, String nullDefaultValue) Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word.formatEnumNameAsTitleCase(T enumValue) Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word.formatEnumNameAsTitleCase(T enumValue, String nullDefaultValue) Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word.
-
Method Details
-
formatEnumNameAsCapitalized
Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase. If the input string is null, returns an empty string.- Parameters:
enumValue- The enum value to convert.- Returns:
- A capitalized string representation of the enum name.
Example: 1. null -> ""
Example: 2. MY_ENUM_VALUE -> My enum value
-
formatEnumNameAsCapitalized
public static <T extends Enum<T>> String formatEnumNameAsCapitalized(T enumValue, String nullDefaultValue) Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase. If the input string is null, returns the specified default value.- Parameters:
enumValue- The enum value to convert.nullDefaultValue- The default value to return if the input is null.- Returns:
- A capitalized string representation of the enum name.
Example: 1. null -> nullDefaultValue
Example: 2. Example: MY_ENUM_VALUE -> My enum value
-
formatEnumNameAsCapitalized
Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase. If the input string is null, returns an empty string.- Parameters:
enumName- The enum name to convert.- Returns:
- A capitalized string representation of the enum name.
Example: 1. null -> ""
Example: 2. Example: MY_ENUM_VALUE -> My enum value
-
formatEnumNameAsTitleCase
Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word. If the enum value is null, returns an empty string.- Parameters:
enumValue- The enum value to be formatted.- Returns:
- A title-cased string representation of the enum value.
Example: 1. null -> ""
Example: 2. MY_ENUM_VALUE -> My Enum Value
-
formatEnumNameAsTitleCase
public static <T extends Enum<T>> String formatEnumNameAsTitleCase(T enumValue, String nullDefaultValue) Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word. If the enum value is null, returns the specified default value.- Parameters:
enumValue- The enum value to be formatted.nullDefaultValue- The default value to return if the input is null.- Returns:
- A title-cased string representation of the enum value.
Example: 1. null -> nullDefaultValue
Example: 2. MY_ENUM_VALUE -> My Enum Value
-
formatEnumNameAsTitleCase
Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word. If the enum value is null, returns an empty string.- Parameters:
enumName- The string representation of the enum value to be formatted.- Returns:
- A title-cased string representation of the enum value.
Example: 1. null -> ""
Example: 2. MY_ENUM_VALUE -> My Enum Value
-
formatEnumNameAsTitleCase
public static <T extends Enum<T>> String formatEnumNameAsTitleCase(String enumName, String nullDefaultValue) Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word. If the enum value is null, returns the specified default value.- Parameters:
enumName- The string representation of the enum value to be formatted.nullDefaultValue- The default value to return if the input is null.- Returns:
- A title-cased string representation of the enum value.
Example: 1. null -> nullDefaultValue
Example: 2. MY_ENUM_VALUE -> My Enum Value
-
formatEnumNameAsSpacedWords
Replaces underscores in the string representation of an enum name with spaces. Does not change letter case. If the input string is null, returns an empty string.- Parameters:
enumValue- The enum value to be formatted.- Returns:
- A string representation of the enum name with underscores replaced by spaces.
Example: 1. null -> ""
Example: 2. MY_ENUM_VALUE -> MY ENUM VALUE
-
formatEnumNameAsSpacedWords
Replaces underscores in the string representation of an enum name with spaces. Does not change letter case. If the input string is null, returns an empty string.- Parameters:
enumName- The string representation of the enum name to be formatted.- Returns:
- A string representation of the enum name with underscores replaced by spaces.
Example: 1. null -> ""
Example: 2. MY_ENUM_VALUE -> MY ENUM VALUE
-
convertToStyleClassName
Converts the enum name to a lower case string, replacing underscores with hyphens, suitable for use as a CSS class name. This method does not accept null values for enumValue.- Parameters:
enumValue- The enum value to be converted. Must not be null.- Returns:
- A string suitable for use as a CSS class name. Example: MY_ENUM_VALUE -> my-enum-value
-
convertAllToStylesClassName
-
convertAllToStylesClassName
-