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

  1. toCamelCase(String)
    Converts a given string to camelCase.

    String camel = CaseConverterUtils.toCamelCase("PascalCaseExample");
    
  2. toPascalCase(String)
    Converts a given string to PascalCase.

    String pascal = CaseConverterUtils.toPascalCase("camel_case_example");
    
  3. toSnakeCase(String)
    Converts a given string to snake_case.

    String snake = CaseConverterUtils.toSnakeCase("Kebab-Case-Example");
    
  4. toKebabCase(String)
    Converts a given string to kebab-case.

    String kebab = CaseConverterUtils.toKebabCase("snake_case_example");
    
  5. toUpperSnakeCase(String)
    Converts a given string to UPPER_SNAKE_CASE.

    String upperSnake = CaseConverterUtils.toUpperSnakeCase("camelCaseExample");
    
  6. toTrainCase(String)
    Converts a given string to Train-Case.

    String train = CaseConverterUtils.toTrainCase("PascalCaseExample");
    
  7. toFlatcase(String)
    Converts a given string to flatcase, with all lowercase letters and no delimiters.

    String flat = CaseConverterUtils.toFlatcase("PascalCaseExample");
    
  8. 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.