Guava CaseFormat Class - Guava

CaseFormat is a utility class to provide conversion between various ASCII char formats.

Class Declaration

Here’s the declaration for com.google.common.base.CaseFormat class:

Enum Constants

Sr.No

Enum Constant & Description

1

LOWER_CAMEL

Java variable naming convention, e.g., "lowerCamel".

2

LOWER_HYPHEN

Hyphenated variable naming convention, e.g., "lower-hyphen".

3

LOWER_UNDERSCORE

C++ variable naming convention, e.g., "lower_underscore".

4

UPPER_CAMEL

Java and C++ class naming convention, e.g., "UpperCamel".

5

UPPER_UNDERSCORE

Java and C++ constant naming convention, e.g., "UPPER_UNDERSCORE".

Methods

Sr.No

Method & Description

1

Converter<String,String> converterTo(CaseFormat targetFormat)

Returns a Converter that converts strings from this format to targetFormat.

2

String to(CaseFormat format, String str)

Converts the specified String str from this format to the specified format.

3

static CaseFormat valueOf(String name)

Returns the enum constant of this type with the specified name.

4

static CaseFormat[] values()

Returns an array containing the constants of this enum type, in the order they are declared.

Methods Inherited

This class inherits methods from the following classes:
  • java.lang.Enum
  • java.lang.Object

Example of CaseFormat Class

Create the following java program using any editor of your choice in say C:/> Guava.
GuavaTester.java

Verify the Result

Compile the class using javac compiler as follows:
Now run the GuavaTester to see the result.
See the result.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Guava Topics