This library provides some static methods of StringCase class that convert string cases between
Ada_Case, camelCase, COBOL-CASE, kebab-case, MACRO_CASE, PascalCase, snake_case, Title Case, and
Train-Case.
In addition, the static methods of StringCase class: capitalize, lowerize, and upperize are
provided to convert string cases with a custom joiner character.
Essentially, these static methods only target ASCII uppercase and lowercase letters for capitalization. All characters other than ASCII uppercase and lowercase letters and ASCII numbers are removed as word separators.
If you want to use some symbols as separators, specify those symbols in the separators field of
an Options instance and use the 〜CaseWithOptions static methods for the desired case.
If you want to retain certain symbols and use everything else as separators, specify those symbols
in keep field of an Options instance and use the 〜CaseWithOptions static methods for the
desired case.
Additionally, you can specify whether to place word boundaries before and/or after non-alphabetic
characters with conversion options.
This can be set using the separateBeforeNonAlphabets and separateAfterNonAlphabets fields in
the Options instance.
The 〜Case static methods that do not take Options as an argument only place word boundaries
after non-alphabetic characters.
In other words, they behave as if
separateBeforeNonAlphabets = false and separateAfterNonAlphabets = true.
This package can be installed from Maven Central Repository.
The examples of declaring that repository and the dependency on this package in
Maven pom.xml and Gradle build.gradle are as follows:
<dependencies>
<dependency>
<groupId>io.github.sttk</groupId>
<artifactId>stringcase</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
repositories {
mavenCentral()
}
dependencies {
implementation 'io.github.sttk:stringcase:1.0.0'
}
The static methods contained in this library are executed as follows:
import com.github.sttk.stringcase.StringCase;
public static void main(String[] args) {
var input = "fooBar123Baz";
var snake = StringCase.snakeCase(input);
System.out.println(snake); // => "foo_bar123_baz"
}If you want the conversion to behave differently, use 〜CaseWithOptions.
import com.github.sttk.stringcase.StringCase;
import com.github.sttk.stringcase.Options;
public static void main(String[] args) {
var opts = new Options(true, true, null, null);
var input = "fooBar123Baz";
var snake = StringCase.snakeCaseWithOptions(input, opts);
System.out.println(snake); // => "foo_bar_123_baz"
}You can also use the static method capitalize, lowerize, and upperize to convert strings into capitalized, lowercased, or uppercased words joined by a custom joiner character:
import com.github.sttk.stringcase.StringCase;
import com.github.sttk.stringcase.Options;
public static void main(String[] args) {
var opts = new Options(true, true, null, null);
var input = "fooBar123Baz";
var output = StringCase.capitalize(input, '.', opts);
System.out.println(snake); // => "Foo.Bar.123.Baz"
}This library supports native build with GraalVM.
See the following pages to setup native build environment on Linux/macOS or Windows.
And see the following pages to build native image with Maven or Gradle.
This framework supports JDK 21 or later.
- Oracle GraalVM 21.0.6+8.1 (java version "21.0.6" 2025-01-21 LTS)
- Oracle GraalVM 25.0.1+8.1 (java version "25.0.1" 2025-10-21 LTS)
Copyright (C) 2024-2026 Takayuki Sato
This program is free software under MIT License.
See the file LICENSE in this distribution for more details.