- Case Recognition: Identify various string cases.
- Case Conversion: Seamlessly convert strings from one case to another.
- Extensible: Easily add or modify case patterns as needed.
- Comprehensive Testing: Robust test suites ensure reliability and correctness.
- Title Case
- lowercase
- UPPERCASE
- camelCase
- PascalCase
- MACRO_CASE
- snake_case
Add the following dependency to your pom.xml if you're using Maven:
<dependency>
<groupId>dev.utano</groupId>
<artifactId>CaseManager</artifactId>
<version>1.0</version>
</dependency>For Gradle, add:
implementation 'dev.utano:CaseManager:1.0'
public class Example {
public static void main(String[] args) {
String text = "hello_world";
Case detectedCase = CaseManager.recogniseCase(text);
System.out.println("Detected Case: " + detectedCase); // Outputs: SNAKE_CASE
}
}public class Example {
public static void main(String[] args) {
String text = "helloWorld";
String converted = CaseManager.convert(text, Case.SNAKE_CASE);
System.out.println("Converted String: " + converted); // Outputs: hello_world
}
}You can use custom implementations of CaseRecogniser for more control:
public class CustomExample {
public static void main(String[] args) {
CaseRecogniser customRecogniser = new CaseRecogniserImpl(); // Or your custom implementation
CaseConverter converter = new CaseConverterImpl(customRecogniser);
String text = "HelloWorld";
String converted = converter.convertTo(text, Case.SNAKE_CASE);
System.out.println("Converted String: " + converted); // Outputs: hello_world
}
}static Case recogniseCase(String text): Detects the case of the provided string.static String convert(String text, Case toCase): Converts the provided string to the specified case.
Represents various string cases with associated regex patterns and token converters.
Holds the result of analyzing a string, including its detected case and tokens.
Defines methods for analyzing and recognizing string cases.
Defines methods for converting strings between different cases.
CaseManager includes comprehensive test classes to ensure functionality:
Ensure you have JUnit set up in your project. You can run the tests using your IDE's test runner or via command line:
For Maven:
mvn test
For Gradle:
gradle test
Contributions are welcome! Please open an issue or submit a pull request for any improvements or feature requests.
This project is licensed under the MIT License.
