Package com.google.common.base
Enum Class CaseFormat
- All Implemented Interfaces:
Serializable
,Comparable<CaseFormat>
,Constable
Utility class for converting between various ASCII case formats. Behavior is undefined for
non-ASCII input.
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionJava variable naming convention, e.g., "lowerCamel".Hyphenated variable naming convention, e.g., "lower-hyphen".C++ variable naming convention, e.g., "lower_underscore".Java and C++ class naming convention, e.g., "UpperCamel".Java and C++ constant naming convention, e.g., "UPPER_UNDERSCORE". -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) String
convert
(CaseFormat format, String s) Enum values can override for performance reasons.converterTo
(CaseFormat targetFormat) Returns a serializableConverter
that converts strings from this format totargetFormat
.private static String
firstCharOnlyToUpper
(String word) (package private) String
normalizeFirstWord
(String word) (package private) abstract String
normalizeWord
(String word) final String
to
(CaseFormat format, String str) Converts the specifiedString str
from this format to the specifiedformat
.static CaseFormat
Returns the enum constant of this class with the specified name.static CaseFormat[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
LOWER_HYPHEN
Hyphenated variable naming convention, e.g., "lower-hyphen". -
LOWER_UNDERSCORE
C++ variable naming convention, e.g., "lower_underscore". -
LOWER_CAMEL
Java variable naming convention, e.g., "lowerCamel". -
UPPER_CAMEL
Java and C++ class naming convention, e.g., "UpperCamel". -
UPPER_UNDERSCORE
Java and C++ constant naming convention, e.g., "UPPER_UNDERSCORE".
-
-
Field Details
-
wordBoundary
-
wordSeparator
-
-
Constructor Details
-
CaseFormat
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
to
Converts the specifiedString str
from this format to the specifiedformat
. A "best effort" approach is taken; ifstr
does not conform to the assumed format, then the behavior of this method is undefined but we make a reasonable effort at converting anyway. -
convert
Enum values can override for performance reasons. -
converterTo
Returns a serializableConverter
that converts strings from this format totargetFormat
.- Since:
- 16.0
-
normalizeWord
-
normalizeFirstWord
-
firstCharOnlyToUpper
-