CaseConverterUtils - MeAlam1/BlueLib GitHub Wiki
CaseConverterUtils
Overview
The CaseConverterUtils
class provides an efficient way to convert strings between a variety of naming conventions. This utility supports transformations to and from camelCase
, PascalCase
, snake_case
, kebab-case
, UPPER_SNAKE_CASE
, Train-Case
, flatcase
, and COBOL-CASE
. It is designed to give you consistent naming conventions throughout your mod.
Getting Started
Conversion Methods
To begin using CaseConverterUtils
, simply call one of its static methods with the input string to convert it to the desired format.
Below is a breakdown of the available methods and their functionality.
Key Methods
-
toCamelCase(String)
Converts a given string to camelCase.String camel = CaseConverterUtils.toCamelCase("PascalCaseExample");
-
toPascalCase(String)
Converts a given string to PascalCase.String pascal = CaseConverterUtils.toPascalCase("camel_case_example");
-
toSnakeCase(String)
Converts a given string to snake_case.String snake = CaseConverterUtils.toSnakeCase("Kebab-Case-Example");
-
toKebabCase(String)
Converts a given string to kebab-case.String kebab = CaseConverterUtils.toKebabCase("snake_case_example");
-
toUpperSnakeCase(String)
Converts a given string to UPPER_SNAKE_CASE.String upperSnake = CaseConverterUtils.toUpperSnakeCase("camelCaseExample");
-
toTrainCase(String)
Converts a given string to Train-Case.String train = CaseConverterUtils.toTrainCase("PascalCaseExample");
-
toFlatcase(String)
Converts a given string to flatcase, with all lowercase letters and no delimiters.String flat = CaseConverterUtils.toFlatcase("PascalCaseExample");
-
toCobolCase(String)
Converts a given string to COBOL-CASE, in uppercase with hyphen delimiters.String cobol = CaseConverterUtils.toCobolCase("camelCaseExample");
Usage Notes
- Error Handling: If an input format is unrecognized, the conversion will default to returning the input string and will log an error.
- Utility Design: This class cannot be instantiated, as it contains a private constructor and only static methods.