Top Description Constructors Methods
com.dlsc.gemsfx.util

public Class EnumUtil

extends Object
Class Inheritance
Imports
org.apache.commons.lang3.StringUtils

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

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T extends Enum<T>> String[]
public static <T extends Enum<T>> String[]
public static <T extends Enum<T>> String

Returns:

A string suitable for use as a CSS class name. Example: MY_ENUM_VALUE -> my-enum-value
convertToStyleClassName
(T
The enum value to be converted. Must not be null.
enumValue
)

Converts the enum name to a lower case string, replacing underscores with hyphens, suitable for use as a CSS class name.

public static <T extends Enum<T>> String

Returns:

A capitalized string representation of the enum name.

Example: 1. null -> ""

Example: 2. MY_ENUM_VALUE -> My enum value

formatEnumNameAsCapitalized
(T
The enum value to convert.
enumValue
)

Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase.

public static <T extends Enum<T>> String

Returns:

A capitalized string representation of the enum name.

Example: 1. null -> nullDefaultValue

Example: 2. Example: MY_ENUM_VALUE -> My enum value

formatEnumNameAsCapitalized
(T
The enum value to convert.
enumValue
,
String
The default value to return if the input is null.
nullDefaultValue
)

Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase.

public static <T extends Enum<T>> String

Returns:

A capitalized string representation of the enum name.

Example: 1. null -> ""

Example: 2. Example: MY_ENUM_VALUE -> My enum value

formatEnumNameAsCapitalized
(String
The enum name to convert.
enumName
)

Converts a string representation of an enum name to a capitalized format, replacing underscores with spaces and making the rest lowercase.

public static <T extends Enum<T>> String

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
(T
The enum value to be formatted.
enumValue
)

Replaces underscores in the string representation of an enum name with spaces.

public static <T extends Enum<T>> String

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
(String
The string representation of the enum name to be formatted.
enumName
)

Replaces underscores in the string representation of an enum name with spaces.

public static <T extends Enum<T>> String

Returns:

A title-cased string representation of the enum value.

Example: 1. null -> ""

Example: 2. MY_ENUM_VALUE -> My Enum Value

formatEnumNameAsTitleCase
(T
The enum value to be formatted.
enumValue
)

Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word.

public static <T extends Enum<T>> String

Returns:

A title-cased string representation of the enum value.

Example: 1. null -> nullDefaultValue

Example: 2. MY_ENUM_VALUE -> My Enum Value

formatEnumNameAsTitleCase
(T
The enum value to be formatted.
enumValue
,
String
The default value to return if the input is null.
nullDefaultValue
)

Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word.

public static <T extends Enum<T>> String

Returns:

A title-cased string representation of the enum value.

Example: 1. null -> ""

Example: 2. MY_ENUM_VALUE -> My Enum Value

formatEnumNameAsTitleCase
(String
The string representation of the enum value to be formatted.
enumName
)

Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word.

public static <T extends Enum<T>> String

Returns:

A title-cased string representation of the enum value.

Example: 1. null -> nullDefaultValue

Example: 2. MY_ENUM_VALUE -> My Enum Value

formatEnumNameAsTitleCase
(String
The string representation of the enum value to be formatted.
enumName
,
String
The default value to return if the input is null.
nullDefaultValue
)

Converts an enum value to title case, replacing underscores with spaces and capitalizing the first letter of each word.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EnumUtilback to summary
private EnumUtil()

Method Detail

convertAllToStylesClassNameback to summary
public static <T extends Enum<T>> String[] convertAllToStylesClassName(Class<T> enumClass)
convertAllToStylesClassNameback to summary
public static <T extends Enum<T>> String[] convertAllToStylesClassName(T[] enumValues)
convertToStyleClassNameback to summary
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:T

The enum value to be converted. Must not be null.

Returns:String

A string suitable for use as a CSS class name. Example: MY_ENUM_VALUE -> my-enum-value

formatEnumNameAsCapitalizedback to summary
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:T

The enum value to convert.

Returns:String

A capitalized string representation of the enum name.

Example: 1. null -> ""

Example: 2. MY_ENUM_VALUE -> My enum value

formatEnumNameAsCapitalizedback to summary
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:T

The enum value to convert.

nullDefaultValue:String

The default value to return if the input is null.

Returns:String

A capitalized string representation of the enum name.

Example: 1. null -> nullDefaultValue

Example: 2. Example: MY_ENUM_VALUE -> My enum value

formatEnumNameAsCapitalizedback to summary
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:String

The enum name to convert.

Returns:String

A capitalized string representation of the enum name.

Example: 1. null -> ""

Example: 2. Example: MY_ENUM_VALUE -> My enum value

formatEnumNameAsSpacedWordsback to summary
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:T

The enum value to be formatted.

Returns:String

A string representation of the enum name with underscores replaced by spaces.

Example: 1. null -> ""

Example: 2. MY_ENUM_VALUE -> MY ENUM VALUE

formatEnumNameAsSpacedWordsback to summary
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:String

The string representation of the enum name to be formatted.

Returns:String

A string representation of the enum name with underscores replaced by spaces.

Example: 1. null -> ""

Example: 2. MY_ENUM_VALUE -> MY ENUM VALUE

formatEnumNameAsTitleCaseback to summary
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:T

The enum value to be formatted.

Returns:String

A title-cased string representation of the enum value.

Example: 1. null -> ""

Example: 2. MY_ENUM_VALUE -> My Enum Value

formatEnumNameAsTitleCaseback to summary
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:T

The enum value to be formatted.

nullDefaultValue:String

The default value to return if the input is null.

Returns:String

A title-cased string representation of the enum value.

Example: 1. null -> nullDefaultValue

Example: 2. MY_ENUM_VALUE -> My Enum Value

formatEnumNameAsTitleCaseback to summary
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:String

The string representation of the enum value to be formatted.

Returns:String

A title-cased string representation of the enum value.

Example: 1. null -> ""

Example: 2. MY_ENUM_VALUE -> My Enum Value

formatEnumNameAsTitleCaseback to summary
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:String

The string representation of the enum value to be formatted.

nullDefaultValue:String

The default value to return if the input is null.

Returns:String

A title-cased string representation of the enum value.

Example: 1. null -> nullDefaultValue

Example: 2. MY_ENUM_VALUE -> My Enum Value