Class EnumUtil

java.lang.Object
com.dlsc.gemsfx.util.EnumUtil

public class EnumUtil extends Object
Utility class for working with enums.

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 Details

    • formatEnumNameAsCapitalized

      public static <T extends Enum<T>> String formatEnumNameAsCapitalized(T enumValue)
      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

      public static <T extends Enum<T>> String formatEnumNameAsCapitalized(String enumName)
      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

      public static <T extends Enum<T>> String formatEnumNameAsTitleCase(T enumValue)
      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

      public static <T extends Enum<T>> String formatEnumNameAsTitleCase(String enumName)
      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

      public static <T extends Enum<T>> String formatEnumNameAsSpacedWords(T enumValue)
      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

      public static <T extends Enum<T>> String formatEnumNameAsSpacedWords(String enumName)
      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

      public static <T extends Enum<T>> String convertToStyleClassName(T enumValue)
      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

      public static <T extends Enum<T>> String[] convertAllToStylesClassName(Class<T> enumClass)
    • convertAllToStylesClassName

      public static <T extends Enum<T>> String[] convertAllToStylesClassName(T[] enumValues)